plot and hold on to a graph after each nested loop in App Designer
2 次查看(过去 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
2 个评论
Mario Malic
2021-2-9
Hi Zeytun,
It's not very clear what do you want to do, maybe it's more suitable to check if minimum width condition is fulfilled and then to plot it.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!