% This M-file reads the results of the KZK simulation (kzk.exe) % The result file (.wvf) corresponds to the waveforms recorded % at the sigma-rho locations defined in the parameter file (.cfg) % This binary file contains: % - number of data points % - time data % - number of watch points % - then, for each watch point: % - sigma % - rho % - pressure data clear; close all; RESdir='c:\KZK\Examples\'; % directory containing the result file name='user_nonlinear.wvf'; % name of the result file IndexPlot=[1 2 3]; % indices of the watchpoints where the waveform should be plotted fp=fopen([RESdir name],'r'); Nbtau=fread(fp,1,'int32'); Nbtau=Nbtau+1; tau=fread(fp,Nbtau,'double'); Nbwatch=fread(fp,1,'int32'); sigma=zeros(Nbwatch,1); rho=zeros(Nbwatch,1); p=zeros(Nbwatch,Nbtau); for ii=1:Nbwatch sigma(ii,1)=fread(fp,1,'double'); rho(ii,1)=fread(fp,1,'double'); p(ii,:)=(fread(fp,Nbtau,'double'))'; end; fclose(fp); for ii=1:length(IndexPlot) index=IndexPlot(ii); figure(ii); hold on; zoom on; plot(tau/(2*pi),p(index,:)); xlabel('\omega_0 t'' / 2\pi'); ylabel('p / p_0'); title(['Waveform at sigma=' num2str(sigma(index)) ', rho=' num2str(rho(index))]); end;