If you repeatedly run the simulation, e.g. using a loop for parameter scans, obj.simResults.iteration is incremented each time the methode run(obj,...) is executed.
Use clearResults(obj) to reset obj.simResults.iteration and obj.simResults
Example
clear all
close all
SHG = chi3D(); %loads standard SHG example
iterations=5;
theta=linspace(SHG.simProp.theta-1e-3,SHG.simProp.theta+1e-3,iterations);
for i=1:iterations
showProgress(SHG,i,iterations); %creates a progress bar showing the remaining time
[Eftfxfy_o Eftfxfy_e] = run(SHG,{'pulse1','theta',theta(i)}); %calculates the standard SHG example for different phasematching angles
end
SHGefficiency=SHG.simResults.SHGexample_green.PulseEnergy./SHG.beamProp.EorI_pulse1;
figure,
subplot(1,2,1);
plot(SHGefficiency), %plots all results saved during the loop
xlabel('result vector');ylabel('SHGefficiency');
subplot(1,2,2);
plot(SHG.simResults.SHGexample_green.z(SHG.simResults.iteration==3)*1e3,SHGefficiency(SHG.simResults.iteration==3)), %polts only the results of iteration 3
xlabel('crystal position (mm)');ylabel('SHGefficiency');
Tino Lang