Error using vertcat and how to solve it?
13 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Md. Golam Zakaria
am 7 Feb. 2023
Bearbeitet: Stephen23
am 7 Feb. 2023
Hello everyone, I am getting Error using vertcat, Dimensions of arrays being concatenated are not consistent, error for the following code. Can anyone please point me out my error and how to fix it.
clc
clear all
f = @(t,x) [-x(4)-(0.424)+(1.6977)*exp(-1.35*10^20*(x(1)^2));
x(4)-(0.663)+(2.6540)*exp(-1.35*10^20*(x(2)^2));
-(2.994*10^5)*x(4);
(7.124*10^17*(x(1)^2)-7.124*10^17*(x(2)^2)+x(3)+60*(cos(t))) -2.55*10^7*x(4)];
[t,xa] = ode45(f,[0, 80],[0,0,-62,0]);
0 Kommentare
Akzeptierte Antwort
Stephen23
am 7 Feb. 2023
Bearbeitet: Stephen23
am 7 Feb. 2023
f = @(t,x) [-x(4)-(0.424)+(1.6977)*exp(-1.35*10^20*(x(1)^2));
x(4)-(0.663)+(2.6540)*exp(-1.35*10^20*(x(2)^2));
-(2.994*10^5)*x(4);
(7.124*10^17*(x(1)^2)-7.124*10^17*(x(2)^2)+x(3)+60*(cos(t)))-2.55*10^7*x(4)];
% ^^ removed space character
A space character is a delimiter that separates elements horizontally, equivalent to a comma. Because of that space character you were trying to concatenate rows together which had [1,1,1,2] columns. Clearly that doesn't work.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices 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!