Error using vertcat and how to solve it?
12 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Md. Golam Zakaria
el 7 de Feb. de 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 comentarios
Respuesta aceptada
Stephen23
el 7 de Feb. de 2023
Editada: Stephen23
el 7 de Feb. de 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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!