From: rams on 2 Apr 2010 12:29 I have a code that generates a curve on a GUI based on 4 input variables. I want to erase old curve every time input variables changed using the sliders in the GUI.A part of my code is... LRT=prospect(2,50,0.025,0.008); plot(LRT(:,1),LRT(:,2),'-b'); % part of code used to generate plot on GUI for the first time code executed protext=['LRT=prospect(get(sli_N,''value''),get(sli_chl,''value''),get(sli_wat,''value''),get(sli_dry,''value''));', ... 'plot(LRT(:,1),LRT(:,2),''-b'');', ... 'xlabel(''Wavelength (nm)'');', ... 'h=legend(''Reflectance'');', ... 'set(h,''Position'',[0.592 0.81 0.24 0.09]);', ... 'axis([400 850 0 1])']; % part of the code used to generate plot whenever the values of inputs changed using sliders on GUI Not sure what to change to erase the old plot whenever input values adjusted using sliders.
From: matt dash on 2 Apr 2010 18:32 p=plot(LRT(:,1),LRT(:,2),''-b''); delete(p) to erase it. or, instead of deleting and replotting, just: set(p,'xdata',LRT(:,1),'ydata',LRT(:,2)) when the sliders change.
From: rams on 6 Apr 2010 11:54 Hi Matt, Thanks for the reply. For both delete(p)and set(p,'xdata',LRT(:,1),'ydata',LRT(:,2)) i am getting following error ??? Error using ==> set(chl_hand,'string',num2str(get(sli_chl,'value')));LRT=prospect(get(sli_N,'value'),get(sli_chl,'value'),get(sli_wat,'value'),get(sli_dry,'value'));delete(p)plot(LRT(:,1),LRT(:,2),'-b');xlabel('Wavelength (nm)');h=legend('Reflectance');set(h,'Position',[0.592 0.81 0.24 0.09]);axis([400 850 0 1]) Error: Unexpected MATLAB expression. ??? Error while evaluating uicontrol Callback
|
Pages: 1 Prev: How do I compress an array of floating numbers in Matlab? Next: Cell array |