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 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (2)
Alan Stevens
el 30 de Nov. de 2020
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 comentarios
Steven Lord
el 30 de Nov. de 2020
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 comentarios
Ver también
Categorías
Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!