필터 지우기
필터 지우기

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

조회 수: 3 (최근 30일)
zeytun
zeytun 2021년 2월 8일
댓글: Mario Malic 2021년 2월 9일
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
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 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