Azzera filtri
Azzera filtri

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 visualizzazione (ultimi 30 giorni)
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)));

Risposta accettata

Torsten
Torsten il 5 Feb 2023
Modificato: Torsten il 5 Feb 2023
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.

Più risposte (0)

Categorie

Scopri di più su Chemistry in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by