Error using vertcat and how to solve it?

조회 수: 12 (최근 30일)
Md. Golam Zakaria
Md. Golam Zakaria 2023년 2월 7일
편집: Stephen23 2023년 2월 7일
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]);

채택된 답변

Stephen23
Stephen23 2023년 2월 7일
편집: Stephen23 2023년 2월 7일
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개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by