フィルターのクリア

Why plot handles in GUI disappear?

1 回表示 (過去 30 日間)
Nir Raviv
Nir Raviv 2016 年 8 月 31 日
コメント済み: Nir Raviv 2016 年 9 月 15 日
Hi, I'm building a GUI with 2 axes and plotting 8 plots on each one of them. On the 1st axes when I get the handles of the second plot the first handle disappears (and so on, so at the end of the loop I have only the 8th plot handle) On the 2nd axes this problem doesn't happen and at the end of this loop I have all the plots handles. My function is happening in the create function of the GUI. This is my code:
function firstPlot(handles)
%%harvesting
plotHandlesHarv = zeros(2,8);
axesHandlesHarv = [handles.LeftAxes,handles.RightAxes];
GraphCheck=[handles.AngCheck handles.SweepCheck handles.HarvCheck handles.VinCheck...
handles.VoutCheck handles.KCheck handles.IrefCheck handles.StepCheck];
set(GraphCheck,'value',1) %pick all the graph lines
set(GraphCheck(8),'value',0); % step graph check is 0
for i = 1:2
plotHandlesHarv(i,1)= plot(axesHandlesHarv(i),0,'-k','LineWidth',2); %ang
hold on
plotHandlesHarv(i,2)= plot(axesHandlesHarv(i),0,'--k','LineWidth',2); %sweep
plotHandlesHarv(i,3)= plot(axesHandlesHarv(i),0,'-r','LineWidth',2); %harvest torque
plotHandlesHarv(i,4)= plot(axesHandlesHarv(i),0,'-b','LineWidth',2); %Vin
plotHandlesHarv(i,5)= plot(axesHandlesHarv(i),0,'-g','LineWidth',2); %Vout
plotHandlesHarv(i,6)= plot(axesHandlesHarv(i),0,'-c','LineWidth',2); %K
plotHandlesHarv(i,7)= plot(axesHandlesHarv(i),0,'--m','LineWidth',2); %Iref
plotHandlesHarv(i,8)= plot(axesHandlesHarv(i),0,'--r','LineWidth',2); %step
hold off
set(axesHandlesHarv(i),'YGrid','on');
set(axesHandlesHarv(i), 'XTickLabelMode', 'Manual');
set(axesHandlesHarv(i), 'XTick', [])
end
Thanks!
  7 件のコメント
Walter Roberson
Walter Roberson 2016 年 9 月 15 日
Which MATLAB version are you using? If you are using R2014b or later, then you should be initializing plotHandlesHarv with gobjects() instead of zeros()
Nir Raviv
Nir Raviv 2016 年 9 月 15 日
Thanks Adam and Walter. Both your answers combined helped me solve this problem

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeGraphics Object Programming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by