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!