簡體   English   中英

Matlab中的常微分方程

[英]Ordinary Differential Equations in 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])

直到現在我還不知道,但是ezplot似乎只為情節的“有趣部分”生成數據點。 因此,如果您指定了ezplot不使用的x限制,您將看不到任何東西。 您需要做的是在ezplot第二個參數中指定x-limits。 然后,您可以使用標准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])

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM