フィルターのクリア

I defined a function that should give me an array with 3 elements, but when I use it it's giving me a lot more than 3.

1 回表示 (過去 30 日間)
function [t,x,N] = lab1(V0,mu,tf) %V0=10 mu=0.4 tf=1
W=1;
g=32.2;
r=5;
tspan=linspace(0,tf,1000);
x0=[0;V0/r];
param=g/r;
[t,x]=ode45(@EOM,tspan,x0,[],param,mu);
% replace 0 below by the expression of N
N=W*r*x(2) + W*g*cos(x(1));
function g=EOM(t,x,param,mu)
% replace 0 below by the expression of G2
g(1,1)=x(2);
g(2,1)=-mu*x(2)^2 + param*(mu*cos(x(1)) - sin(x(1)));

採用された回答

Torsten
Torsten 2023 年 2 月 5 日
編集済み: Torsten 2023 年 2 月 5 日
Maybe you mean
V0=10;
mu=0.4 ;
tf=1;
[t,x,N] = lab1(V0,mu,tf);
hold on
plot(t,x)
plot(t,N)
hold off
grid on
function [t,x,N] = lab1(V0,mu,tf) %V0=10 mu=0.4 tf=1
W=1;
g=32.2;
r=5;
tspan=linspace(0,tf,1000);
x0=[0;V0/r];
param=g/r;
[t,x]=ode45(@(t,x)EOM(t,x,param,mu),tspan,x0);
% replace 0 below by the expression of N
N=W*r*x(:,2) + W*g*cos(x(:,1));
end
function g=EOM(t,x,param,mu)
% replace 0 below by the expression of G2
g(1,1)=x(2);
g(2,1)=-mu*x(2)^2 + param*(mu*cos(x(1)) - sin(x(1)));
end
If not, you will have to tell us which 3 elements you want to get.
  1 件のコメント
Melhem
Melhem 2023 年 2 月 5 日
Thanks a lot. I've learned MATLAB a very long time ago and I'm a little bit rusty.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeChemistry についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by