필터 지우기
필터 지우기

Same number of columns, but getting "Dimensions of arrays being concatenated are not consistent" error

조회 수: 1 (최근 30일)
The two arrays I'm trying to concatenate are both of column size 1, so why am I unable to horzcat them?

답변 (1개)

Waseem AL Aqqad
Waseem AL Aqqad 2021년 2월 21일
편집: Waseem AL Aqqad 2021년 2월 21일
Hi Liam,
Your two arrays should have the same number of rows when you use horzcat.
d=[1;2;3;4;5;6;7];
f=[3;4;5;6;7;8;9];
horzcat(d,f)
Here is another example where f and d have different no. of columns but same no. of rows
f=[4 5;4 5;6 7;7 8;3 2;3 4;6 7];
d=[1;2;3;4;5;6;7];
horzcat(d,f)
  댓글 수: 2
Liam Neville
Liam Neville 2021년 2월 21일
Waseem,
So if i was trying to run this code:
coeff=corrcoef([y,y1]);
How would I go about it?
y is 256x1 and y1 is 22x1.
Waseem AL Aqqad
Waseem AL Aqqad 2021년 2월 21일
편집: Waseem AL Aqqad 2021년 2월 21일
Is it fine if we use vertcat?
y=ones(256,1);
y1=zeros(22,1);
[y;y1]; % or vertcat(y,y1);

댓글을 달려면 로그인하십시오.

카테고리

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

태그

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by