After a small search, I see that updateSystem works specifically for dynamic system response plots -- not what I've evaluated into the second argument. Is there a command that accomplishes what I'm trying to accomplish but for non-transfer functions?
"Error While Evaluating UIControl Callback"
7 次查看(过去 30 天)
显示 更早的评论
I'm attempting to write a script that allows me to change the Damping Ratio value via a slider. The code below line 10 is not my code, and is copied from someone doing something similar but with a transfer function. It seems that the issue is in line 25 with the system update.
close all
clear all
zeta = .5; % Damping Ratio
wn = 2; % Natural Frequency
v = 0:.001:.05
Yo = 5E-2; M = 2000; k = 200;
w = sqrt(k/M);
lambda = .5; wf = (2*pi*v)/(lambda); xi = .5;
r = wf/w
x = Yo*(sqrt(1+(2*r.*xi).^2)./sqrt((1-r.^2).^2+(2*r.*xi).^2))
f = figure;
ax = axes('Parent',f,'position',[0.13 0.39 0.77 0.54]);
h = plot(v,x)
b = uicontrol('Parent',f,'Style','slider','Position',[81,54,419,23],...
'value',xi, 'min',0, 'max',1);
bgcolor = f.Color;
bl1 = uicontrol('Parent',f,'Style','text','Position',[50,54,23,23],...
'String','0','BackgroundColor',bgcolor);
bl2 = uicontrol('Parent',f,'Style','text','Position',[500,54,23,23],...
'String','1','BackgroundColor',bgcolor);
bl3 = uicontrol('Parent',f,'Style','text','Position',[240,25,100,23],...
'String','Damping Ratio','BackgroundColor',bgcolor);
b.Callback = @(es,ed) updateSystem(h, Yo*(sqrt(1+(2*r.*(es.Value).^2)./sqrt((1-r.^2).^2+(2*r.*(es.Value)).^2))));
回答(1 个)
Asvin Kumar
2021-5-20
If I understand correctly, you just want to update the plot. You can do that by calling the plot function in your callback with the appropriate handle so that the previous plot gets overwritten. Something like...
b.Callback = @() plot(h.Parent, ...) % fill in your expression in the 2nd and 3rd args
If you don't want the previous plot to get overwritten, you could use:
hold on
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!