Info

This question is closed. Reopen it to edit or answer.

Unable to perform assignment because the left and right sides have a different number of elements.

1 view (last 30 days)
hello,
can anyone tell me why I'm getting this error message in line 16. I'm not very good with MATLAB but I need to solve this O.D.E using Eulers numerical method. Thanks.
clear all;
clc;
k=-0.1865;
te0=0;
Te0=100;
teF=50;
h=0.01;
n=(teF-te0)/h;
te_=[te0:h:teF];
Te_= zeros(n+1,1);
Te_(1)=Te0;
for i=1:n
fi=k*(Te_(i)-30);
Te_(i+1)=Te_+h*fi;
end

Answers (1)

James Tursa
James Tursa on 25 Apr 2019
I would assume this
Te_(i+1)=Te_+h*fi;
was meant to be this
Te_(i+1) = Te_(i) + h * fi;

Tags

Community Treasure Hunt

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

Start Hunting!