Error using horzcat Dimensions of arrays being concatenated are not consistent?
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Najmeh Eskandari
am 14 Jan. 2019
Kommentiert: Stephen23
am 27 Mai 2019
hello. i solve some differential equation with ode45. The answers are correct and there is no error.because i want to show some variables that are not in diffrential equation i use the command:
[dx phee] =melanie_ode_fj(t,Y)
but there is this error:
Error using horzcathorzcat
Dimensions of arrays being concatenated are not consistent.
i do not know why ? the codes run correctly and there is no error.
codes are long so i attach them.
you should run MAIN.
Thanks
2 Kommentare
Jan
am 14 Jan. 2019
Bearbeitet: Guillaume
am 14 Jan. 2019
Please post the complete error message. Where does the problem occur?
Users, who try to help you, might loose their current work by your evil clear all. Use functions to keep your workspace clean instead of a brutal clearing, which wastes a lot of time.
Akzeptierte Antwort
Star Strider
am 14 Jan. 2019
Your ‘melanie_ode_fj’ function has only one output (as it should):
function dx=melanie_ode_fj(t,x)
If you want other outputs from it, create a second version of it (with a slightly different name, I call it ‘melanie_ode_fj_more_outputs’ here) with the outputs you want.
Then, use a for loop and the results of the original ‘melanie_ode_fj’ integration to get the other information you want.
For example (assuming your time vector is ‘t’):
for k = 1: numel(t)
[dx{k} phee{k}] = melanie_ode_fj_more_outputs(t(k),Y(k));
end
NOTE: This is UNTESTED CODE and is for illustration purposes only!
3 Kommentare
Star Strider
am 14 Jan. 2019
Because the ODE function has only one output, as it should. To return more variables without significantly complicating the ODE solver call, a second function that creates and returns the necessary variables is the easiest solution.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Ordinary Differential Equations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!