Trying to plot 3-d

조회 수: 1 (최근 30일)
Avan Al-Saffar
Avan Al-Saffar 2014년 8월 8일
댓글: Yu Jiang 2014년 9월 3일
My equation is
dxdt=N0*sin(omega*t)*x*(1-x/K);
N0=1:1:10;
omega=1:1:10;
I want to plot 3-D for N0,omega,Xmax and Xmean.
I am trying with the following code but it does not work.
function RunOsciliationsky3D
N0all= 1:1:10;
N=length(N0all);
omegaall= 1:1:10;
M=length(omegaall);
Pmax=zeros(N,M);
Pmean=zeros(N,M);
Pall=[Pmax,Pmean];
x=size(Pall);
for i=1:N
for j =1:N
[t,x]=ode45(@osciliation,[0 100],0.1,[],N0all(i),10,omegaall(j));
Pall(i,j)=x;
end
end
[N0x,omegay]=meshgrid(N0all,omegaall);
h=mesh(N0x,omegay,Pall);
1;
  댓글 수: 1
Andy L
Andy L 2014년 8월 8일
What error are you getting? I have tried copying and pasting but the function in your optimisation function isn't included.

댓글을 달려면 로그인하십시오.

채택된 답변

Yu Jiang
Yu Jiang 2014년 8월 8일
See the files I revised as attached. It can generate Pmean. Similarly you can plot Pmax. Notice that it is not clear what K is, so I let it be 0.15. I also force N0 to take negative values since positive values make the system unstable.
Hope it helps.
- Yu
  댓글 수: 2
Avan Al-Saffar
Avan Al-Saffar 2014년 9월 1일
Dear Yu Jiang
Thank you for your previous help, but I need more help please if you have any advice?
I've chosen K=10 and N0 to get a positive values. I got the result which I am not happy with it and I got this error message:
Warning: Failure at t=8.083150e+01. Unable to meet integration tolerances without reducing the step size below the smallest value allowed (2.273737e-13)at time t.
> In ode45 at 308
In Runanswertest at 13
Warning: Failure at t=8.701882e+01. Unable to meet integration tolerances without reducing the step size below the smallest value allowed (2.273737e-13) at time t.
> In ode45 at 308
In Runanswertest at 13
Warning: Failure at t=3.011651e+01. Unable to meet integration tolerances without reducing the step size below the smallest value allowed (5.684342e-14) at time t.
> In ode45 at 308
In Runanswertest at 13
Warning: Failure at t=5.698339e+00. Unable to meet integration tolerances without reducing the step size below the smallest value allowed (1.421085e-14)at time t.
> In ode45 at 308
In Runanswertest at 13
Note: I thought to remove the initial transient period or just to reduce the time step but I am really confused about this code .
Yu Jiang
Yu Jiang 2014년 9월 3일
When N0 is positive, the system can easily become unstable. Therefore, the initial condition should be reduced.
Please make the three changes based on the code I provided.
Line 12 of RunOsciliationsky3D.m : Change 0.1 to 0.01 or less
Line 2 of oscillation.m: Change K = 1 to K = 10
Line 3 of oscillation.m: Change x/0.15 to x/K.
This should work.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by