i frustrated this, because every method found online not work me. can display str rather pass on variable. e.g.
h = uicontrol('style','slider','callback',@(src,evt)disp(get(src,'value'))); addlistener(h,'value','preset',@(~,~)disp('hi'));
if replace disp function callback, error saying there no 'value' property. here code
zeta = .5; % damping ratio wn = 2; % natural frequency sys = tf(wn^2,[1,2*zeta*wn,wn^2]); f = figure; ax = axes('parent',f,'position',[0.13 0.39 0.77 0.54]); h = stepplot(ax,sys); setoptions(h,'xlim',[0,10],'ylim',[0,2]); b = uicontrol('parent',f,'style','slider','position',[81,54,419,23],... 'value',zeta, 'min',0, 'max',1,'callback',@(s,e)updatesystem(h,tf(wn^2,[1,2*s.value*wn,wn^2]))); addlistener(b,'value','postset',@(s,e)updatesystem(h,tf(wn^2,[1,2*s.value*wn,wn^2])))
"no appropriate method, property, or field 'value' class 'matlab.graphics.internal.graphicsmetaproperty'."
in other example, there 'continuousvaluechange', 'actionevents', not work.
can give me simple example slider give continuous output on value?
thanks
in listener line variable s
listener object not uicontrol variable (b).
updating simple example be:
figure; h = uicontrol('style','slider','callback',@(src,evt)disp(get(src,'value'))); addlistener(h,'value','preset',@(~,~)disp(h.value));
Comments
Post a Comment