Borrar filtros
Borrar filtros

error about Euler method

2 visualizaciones (últimos 30 días)
Antonino Tirino
Antonino Tirino el 31 de Dic. de 2020
Comentada: Antonino Tirino el 2 de En. de 2021
Hi guys, can anyone hepl me? I have to solve two differential equations with the Euler method. They are V(i+1)=... and gamma(i+1)=...
Thanks.
The ERROR is:
Unable to perform assignment because the left and right sides have a different number of elements.
Error in (line 56)
V(i+1)=V(i)+(((0.5*rho(i)*V(i))/(sin(gamma(i))))*B - g(i)/V(i))*Delta_H;
And the SCRIPT is:
FILE=importdata('FILE.dat',',');
H=FILE.data(:,1))*1000; % [m]
g=FILE.data(:,2); % [m/s^2]
T=FILE.data(:,3); % [K]
rho=FILE.data(:,4); % [Kg/m^3]
P=FILE.data(:,5); % [K/Kmol]
lambda=FILE.data(:,6); % [m]
R_0=6378000;
n=length(H);
V(1)=7500; % [m/s] initial value of V
gamma(1)=convang(1.5,'deg','rad'); %initial value of gamma
for i=1:(n-1)
Delta_H=H(i+1)-H(i);
R=R_0+H(i);
V(i+1)=V(i)+(((0.5*rho(i)*V(i))/(sin(gamma(i))))*B - g(i)/V(i))*Delta_H;
gamma(i+1)=gamma(i)*+(1/(R*(sin(gamma(i)))) ...
-((g(i)/(V(i)^2))*(1/(tan(gamma(i))))))*Delta_H;
end
gamma_deg=convang(gamma,'rad','deg');
figure(1)
plot(V,(H/1000),'k-','Linewidth',1.15)
figure(2)
plot(gamma_deg,(H/1000),'k-','Linewidth',1.15)

Respuestas (1)

Walter Roberson
Walter Roberson el 31 de Dic. de 2020
B is not defined in the code. It has whatever value is left over in the workspace.
  3 comentarios
Walter Roberson
Walter Roberson el 2 de En. de 2021
The cause of the error is that B is not a scalar at the time the problem occurs.
dbstop if error
run the code. When it stops examine the size of B and then the size of each of the subexpressions.
Antonino Tirino
Antonino Tirino el 2 de En. de 2021
I solved the cause of error. Thanks.

Iniciar sesión para comentar.

Categorías

Más información sobre Ordinary Differential Equations en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by