How to solve this error?

3 次查看(过去 30 天)
Biza Ferreira
Biza Ferreira 2017-2-3
评论: Torsten 2017-2-3
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 个评论
Torsten
Torsten 2017-2-3
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.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by