error about Euler method

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)

回答(1 个)

Walter Roberson
Walter Roberson 2020-12-31

0 个投票

B is not defined in the code. It has whatever value is left over in the workspace.

3 个评论

The variable "B" is defined even if it is not present here because I forgot to report it, but in the code I have executed it is present and It Is a scalare value. What could the cause of the error?
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.
I solved the cause of error. Thanks.

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 Symbolic Math Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by