2015-12-15 45 views
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中

回答

2

替換grid on有:

grid (handles.velocity_axes,'on') 
grid (handles.amplitude_axes,'on') 

這是因爲只對當前軸gcagrid作品命令形式。在特定軸上繪圖不會使這些軸保持最新狀態,因此第二個grid on將再次應用於當前軸,這恰好是幅度圖。

+0

非常感謝,修好了! –

相關問題