Hi everybody
I am trying to solve a couples ODE system, I wrote the code below but it has an error. I changed the code several times but it didnt work. How can I fix it???
thank you.

3 件のコメント

Rik
Rik 2021 年 1 月 25 日
If you had pasted your code as code, others can actually run it.
Mohammad Hasn Hashemi
Mohammad Hasn Hashemi 2021 年 1 月 25 日
function Idot=motor(t,Z)
Zdot=zeros(2,1);
Rs=0.1;
Ls=0.5;
W=314;
B=0;
time=0:0.1:5;
% va=100*sin(W*t-B);
% vb=100*sin(W*t-B-(pi/2));
% Zdot(1)=(-Rs*Z(1)+100*sin(W*time-B))/Ls;
% Zdot(2)=(-Rs*Z(2)+100*sin(W*time-B-(pi/2)))/Ls;
Zdot(1)=(-Rs*Z(1)+100*sin(W))/Ls;
Zdot(2)=(-Rs*Z(2)+100*sin(W-(pi/2)))/Ls;
end
clc
clear
t=[0,5];
x0=0;
xdot0=5;
z0=[x0,xdot0];
[T,Z]=ode45(motor,t,z0)
plot(T,Z)
Walter Roberson
Walter Roberson 2021 年 1 月 25 日
function Idot=motor(t,Z)
output should be Zdot not Idot

サインインしてコメントする。

 採用された回答

Alan Stevens
Alan Stevens 2021 年 1 月 25 日
編集済み: Rik 2021 年 1 月 25 日

0 投票

More like this:
t=0:0.1:5;
x0=0;
xdot0=5;
z0=[x0,xdot0];
[T,Z]=ode45(@motor,t,z0); % Note @motor, not just motor.
plot(T,Z)
function Zdot=motor(t,Z)
Zdot=zeros(2,1);
Rs=0.1;
Ls=0.5;
W=314;
%B=0;
Zdot(1)=(-Rs*Z(1)+100*sin(W*t))/Ls;
Zdot(2)=(-Rs*Z(2)+100*sin(W*t-(pi/2)))/Ls;
end
(code executed by @Rik)

2 件のコメント

Mohammad Hasn Hashemi
Mohammad Hasn Hashemi 2021 年 1 月 25 日
Output argument "Idot" (and maybe others) not assigned during call to "motor".
Error in odearguments (line 90)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 115)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in motor2 (line 9)
[T,Z]=ode45(@motor,t,z0)
Still having Error
Alan Stevens
Alan Stevens 2021 年 1 月 25 日
I corrected the other errors! Copy and paste the coding. Look carefully at the other lines.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Community Treasure Hunt

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

Start Hunting!

Translated by