2014-02-23 51 views
1

提問 -Matlab中的常微分方程

我正在研究解決2個一階微分和2個二階微分的一些matlab代碼。我確定dsolve(),但是當我想繪製我目前正在使用ezplot,它並沒有給我我想要的。我想用四個圖形產生一個窗口。我知道我會使用副劇,但我不知道如何,一個例子會很好。另外,我不知道如何讓我的地塊不僅僅是一個大面積的重要區域。我的代碼如下:

close all % close all figure windows that are open 
clear all % clear all the variables currently stored in memory 
clc  % clear the commands in the command window 

%%Problem 1%%%%% 
a = (dsolve('Dv = -500*v+5000','v(0)=5')); 
display (a) 
b = (dsolve('Dx = -2000*x+100','x(0)=-.02')); 
display (b) 

%%Problem 2%%%%% 
c = (dsolve('D2y+2000*Dy+26000000*y-520000000=0','Dy(0)=0','y(0)=5')); 
display(c) 
d = (dsolve('D2y+100*Dy+2500*y-520000000=0','Dy(0)=20','y(0)=0')); 
display (d) 

figure 
ezplot(a); 
axis([0,.01,4,10]) 

figure 
ezplot(b); 
axis([0,.01,0,10]) 

figure 
ezplot(c); 
axis([0,.01,4,10]) 

figure 
ezplot(d); 
axis([0,.01,4,10]) 

回答

2

我不知道沒有到現在爲止,但似乎ezplot僅供情節「有趣的部分」產生的數據點。因此,如果您指定ezplot未使用的x限制,則看不到任何內容。你需要做的是在第二個參數ezplot中指定x限制。然後,您可以使用標準suplot函數創建子圖,獲取軸手柄並指定軸。你的代碼的繪圖部分應該是這樣的。

figure 
h1=subplot(2,2,1); 
ezplot(a, [0,0.01]); 
axis(h1,[0,0.01,4,10]) 

h2=subplot(2,2,2); 
ezplot(b, [0,0.01]); 
axis(h2,[0,.01,0,10]) 

h3=subplot(2,2,3); 
ezplot(c, [0,0.01]); 
axis(h3,[0,.01,4,10]) 

h4=subplot(2,2,4); 
ezplot(d, [0,0.01]); 
axis(h4,[0,.01,4,10]) 
+0

謝謝你這個工作,我其實需要放大這些「有趣的部分」,但我有一個好主意該怎麼做。感謝您的幫助 – user2444074

+0

更新:我開始嘗試改變軸的值,如上所述,我記得命令軸緊;這解決了圖問題中「有趣」的部分。 – user2444074