How can I define the variable handles for this code. A is a numerical value not text "Undefined variable handles or class "handles.A"
조회 수: 3 (최근 30일)
이전 댓글 표시
xo = 0.1; vo = 3;
m = 1; c =10; k = 100
wn = sqrt(k/m); c_c = 2*m*wn; xeta = c/c_c;
t = 2*pi
A=(sqrt(((wn^2)*(xo^2))+(vo^2)))/wn;
set(handles.A,'String','A')
phi=atan((wn*xo)/vo);
set(handles.phi,'String',phi)
xt=A.*sin(wn.*t+phi);
axes(handles.axes2)
ylabel('x(t)')
xlabel ('t')
elif zeta<1
wd=wn*(sqrt(1-(zeta^2)));
set(handles.damping_frequency,'String',wd)
A=sqrt((((vo+zeta*wn*xo)^2)+((xo*wd)^2))/(wd^2));
set(handles.A,'String',A)
phi=atan((xo*wd)/(vo+zeta*wn*xo));
set(handles.phi,'String',phi)
xtud=A.*exp(-zeta*wn.*t).*sin(wd.*t+phi);
axes(handles.axes1)
ylabel('x(t)')
xlabel ('t')
댓글 수: 0
답변 (2개)
Alan Stevens
2020년 11월 30일
Do you want something like this?
xo = 0.1; vo = 3;
m = 1; c =10; k = 100;
wn = sqrt(k/m); c_c = 2*m*wn; zeta = c/c_c;
t = linspace(0,2*pi,100);
if zeta>=1
A=(sqrt(((wn^2)*(xo^2))+(vo^2)))/wn;
phi=atan((wn*xo)/vo);
xt=A.*sin(wn.*t+phi);
plot(t,xt),grid
ylabel('x(t)')
xlabel ('t')
elseif zeta<1
wd=wn*(sqrt(1-(zeta^2)));
A=sqrt((((vo+zeta*wn*xo)^2)+((xo*wd)^2))/(wd^2));
phi=atan((xo*wd)/(vo+zeta*wn*xo));
xtud=A.*exp(-zeta*wn.*t).*sin(wd.*t+phi);
plot(t,xtud),grid
ylabel('x(t)')
xlabel ('t')
end
If you really want to store data in a variable called handles then use
handles.A = A;
and suchlike.
댓글 수: 0
Steven Lord
2020년 11월 30일
Generally speaking, usually code that involves a struct array named handles is part of a GUI created using GUIDE. If you're trying to extract the code from one of the callbacks of that GUI and use it as a computational routine instead of part of the UI, you can probably just remove those lines from your copy of the callback code.
댓글 수: 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!