How to solve this error?

3 vues (au cours des 30 derniers jours)
Biza Ferreira
Biza Ferreira le 3 Fév 2017
Commenté : Torsten le 3 Fév 2017
Hello Friends, I have a small problem, I am solving a first order equation problem, and i use euler, heund, range-kutta, and ode45 methods, so when I try display a table in the matlab command Window devolve me the following error:
Error using horzcat Dimensions of matrices being concatenated are not consistent.
if true
% code
clear all
tic;
h=0.1;
format short g
[t,ya]=euler(@funObj,0,1,h,1);
[t,yc]=heun(@funObj,0,1,h,1);
[t,yd]=runge4(@funObj,0,1,h,1);
[t,zf]=ode45(@funObj,tspan,1);
dim = length(t);
yx=yd;
disp('------METODO EULER, EULER MOD., HEUN , RUNGE-KUTTA, ODE23 , ODE45 , ODE113 , SOL. EXATA------');
disp('t(i) ye(i) yem(i) yh(i) yk(i) y23(i) y45(i) y113(i) sol. exacta');
disp('------------------------------------------------------------------------------------------------');
disp([t(1:dim), ya(1:dim) , yb(1:dim) , yc(1:dim) , yd(1:dim) , y23(1:dim) , y45(1:dim) , y113(1:dim) , yx(1:dim)])
disp('------------------------------------------------------------------------------------------------');
end
  1 commentaire
Torsten
Torsten le 3 Fév 2017
Check where the error happens.
If it happens in the line
disp([t(1:dim), ya(1:dim) , yb(1:dim) , yc(1:dim) , yd(1:dim) , y23(1:dim) ,...
check whether the length of t is the same after each call to the respective integrator.
Best wishes
Torsten.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by