0
if zeta < 1
omegad = omegan*sqrt(1-zeta^2);
c1 = y0;
c2 = ydot0/(omegan);
p1 = (-zeta*omegan)+(omegan)*sqrt((zeta^2)-1);
p2 = (-zeta*omegan)-(omegan)*sqrt((zeta^2)-1);
x = c1*exp(p1*t)+c2*exp(p2*t);
xdot = p1*c1*exp(p1*t)+p2*c2*exp(p2*t);
set(handles.omegad_output,'String',omegad);
elseif zeta == 1
omegad = omegan*sqrt(1-zeta^2);
c1 = y0;
c2 = ydot0/(omegan);
x = c1*exp(-omegan.*t)+c2.*t*exp(-omegan.*t);
xdot = -omegan*c1*exp(-omegan.*t)-omegan*c2*t*exp(-omegan*t)+t*exp(-omegan*t);
set(handles.omegad_output,'String',omegad);
else
omegad = omegan*sqrt(1-zeta^2);
c1 = y0;
c2 = (ydot0+zeta*omegan*y0)/omegad;
x = exp(-zeta*omegan.*t).*(c1*cos(omegad.*t)+c2*sin(omegad.*t));
A = -zeta*omegan*exp(-zeta*omegan.*t);
B = c1*cos(omegad.*t)+c2*sin(omegad.*t);
C = exp(-zeta*omegan.*t);
D = -c1*omegad*sin(omegad.*t)+c2*omegad*cos(omegad.*t);
xdot = A.*B+C.*D;
set(handles.omegad_output,'String',omegad);
end
% Create Amplitude plot in proper axes
plot(handles.amplitude_axes,t,x)
set(handles.amplitude_axes,'XMinorTick','on')
grid on
% Create Velocity plot in proper axes
plot(handles.velocity_axes,t,xdot)
set(handles.velocity_axes,'XMinorTick','on')
grid on
在構建GUI時,這裏是繪圖按鈕回調函數。我有上面的代碼,當我繪製它時,網格線只出現在幅度圖而不是速度圖上,我怎麼讓網格線顯示這兩個圖。爲什麼網格線不會出現在matlab中
非常感謝,修好了! –