Hi I want to iterate an array in a for loop but within a while loop if this makes sense. Im trying to set the condition where while the value of diameter is less than that of final diameter, the loop executes code which is stored in an empty array but I'm not sure how to do this. I'm trying to set up the for loop so that it executes until the array is filled ie until the values of diameter reach the value of diameter final? Thanks in advance for your help :-)
focal_length = 50e-02;
m = 1;
diameter = 0.5e-03
diameter_final = 6e-03;
wavelength = 450e-06
diameter_a = {}
wavelength_a = {}
while diameter <= diameter_final
for size(diameter_a{}) < 1:6
theta = atand(diameter/focal_length);
d = (m*wavelength/sin(theta));
spatial_freq = 1/d
diameter_a = diameter + 0.5e-03
wavelength_a = wavelength + 5e-05
plot(diameter_a, spatial_freq,"r,--*")
ylabel("Spatial frequency (lines/mm)")
hold on
plot(wavelength_a,spatial_freq,"k")
end
end