# How to solve this error?

1 view (last 30 days)
Biza Ferreira on 3 Feb 2017
Commented: Torsten on 3 Feb 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
Torsten on 3 Feb 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.

### Categories

Find more on Ordinary Differential Equations in Help Center and File Exchange

### Community Treasure Hunt

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

Start Hunting!