Please help me an error occur

조회 수: 1 (최근 30일)
ATHUMANI SIZYA
ATHUMANI SIZYA 2021년 10월 18일
답변: Steven Lord 2021년 10월 18일
A=[1:5;6:-0.2:5.2;13 4 - 3 1 30;x 4 9]
Error using vertcat
Dimensions of arrays being concatenated are not consistent
WHat should i do to remove that error

답변 (1개)

Steven Lord
Steven Lord 2021년 10월 18일
Let's look at each of the terms you're trying to concatenate together.
term1 = 1:5
term1 = 1×5
1 2 3 4 5
term2 = 6:-0.2:5.2
term2 = 1×5
6.0000 5.8000 5.6000 5.4000 5.2000
term3 = [13 4 - 3 1 30]
term3 = 1×4
13 1 1 30
% term4 = [x 4 9]
The space around the minus sign in term3 makes MATLAB treat that part as (4-3) not [4, -3] as I suspect you intended. I recommend separating the elements in that term with commas to clearly indicate to MATLAB where each element begins and ends.
term3 = [13, 4, - 3, 1, 30]
term3 = 1×5
13 4 -3 1 30
For your fourth term, that will be a 1-by-5 vector as well if x is a 1-by-3 vector. You haven't shown us x so I can't tell if that will also be a problem in creating your matrix.

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by