plot and hold on to a graph after each nested loop in App Designer

3 次查看(过去 30 天)
Hi,
I have a nested for loop in App Designer, which I am using to change two parameters (AOIc and Lgc) and to plot a graph after each loop. After each nested loop I am calculating the minimum width of the graphs. I want to hold on to the graphs with minimum widths and to hold off all the others. By other words, at the very end I want to have only the graphs with minimum width.
Please see the portion of my code that is trying to do this. In its current state, it plots the one with minumum width after the first loop and loses the ones that are not necessary (that's good!), but after the second loop it also loses the first minimum.
% initial conditions
AOIc = app.AOIc.Value; % deg
AOIc_step = app.AOIc_step.Value; % deg
AOIc_number = app.AOIc_number.Value;
AOIc0 = AOIc - AOIc_step*AOIc_number/2;
AOIcstart = app.AOIc.Value; % deg
Lgc = app.Lgc.Value; % cm
Lgc_step = app.Lgc_step.Value; % cm
Lgc_number = app.Lgc_number.Value;
Lgc0 = Lgc - Lgc_step*Lgc_number/2;
Lgcstart = app.Lgc.Value; % deg
tlim = app.tlim.Value;
tstep = app.tstep.Value;
t = -tlim:tstep:tlim; % time (fs)
durt = NaN(AOIc_number+1,Lgc_number+1); % array of temporal duration (or width) values to be filled after each loop
for k = 1:AOIc_number+1
AOIc(k) = AOIc0 + (k-1)*AOIc_step;
app.AOIc.Value = AOIc(k);
app.AOIc_number.Value = k;
drawnow()
for kk = 1:Lgc_number+1
Lgc(kk) = Lgc0 + (kk-1)*Lgc_step;
app.Lgc.Value = Lgc(kk);
app.Lgc_number.Value = kk;
drawnow()
CalculatepButtonPushed(app, event) % calculates and plots pulse on UIAxes1 using "CalculatepButtonPushed" function above
drawnow()
I = app.I2; % property
Iarray(kk,:) = I;
app.dur.Value = width(I)*tstep;
durt(k,kk) = app.dur.Value;
end
[min_durt0,y0] = min(durt(k,:));
hold(app.UIAxes1, 'off')
plot(app.UIAxes1,t,Iarray(y0,:),'w','LineWidth',2)
hold(app.UIAxes1, 'on')
pause(1)
end

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Filter Analysis 的更多信息

产品


版本

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by