Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

differential Equations with ode45

1 Ansicht (letzte 30 Tage)
Alex Pak
Alex Pak am 28 Nov. 2014
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
Hi! Please help solve the differential equation with ode45. The problem is: I can't find Uk (it's value Vy in the previous step).
function odefun100
t0=0;
tk=0.05;
[T,Y]=ode45(@odefun12, [t0 tk],0);
nT=numel(T);
Vy=zeros(nT,1);
L1=zeros(nT,1);
L=zeros(nT,1);
Uk=zeros(nT,1);
for ik=1:nT
[~,Vy(ik,1),L1(ik,1),L(ik,1),Uk(ik,1)]=odefun12(T(ik),Y(ik,:));
end
plot(T,Vy,T,Uk)
function [dy, Vy, L1 L Uk]=odefun12(t,y)
N=0;
Uk=0;
Uk=N;
L2=y(1);
E=randn;
b=exp(-0.1*0.1);
Vy=b*Uk + 2*sqrt(1-b^2)*E;
L1=0.006*Vy;
dy=zeros(1,1);
dy(1)=0.01*Vy-5*L2;
L=L1+L2;
N=Vy;
end
end
Why Uk=0?

Antworten (1)

Orion
Orion am 28 Nov. 2014
Bearbeitet: Orion am 28 Nov. 2014
Hi,
you wrote :
function [dy, Vy, L1 L Uk]=odefun12(t,y)
N=0;
Uk=0;
Uk=N;
=> Uk = N = 0 whatever the inputs are.
you forget to code something
  1 Kommentar
Alex Pak
Alex Pak am 28 Nov. 2014
thank you, you are right, but I need Uk, Uk is Vy, but on the previous step of calculating.
I know how to solve this problem in the simple case. For example:
N=0;
Uk=0;
x=0:9;
for i=1:10;
Uk(i)=N;
E(i)=randn;
b=exp(-0.1*0.1);
Vy(i)=b*Uk(i) + 2*sqrt(1-b^2)*E(i);
N=Vy(i);
end
plot(x,Vy,x,Uk)
Please tell me, how can I solve this problem with ode45?

Diese Frage ist geschlossen.

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by