Insert first element into existing column vector...

Hello,
I am trying to just insert a 0 into my 48x1 double vector z, like this:
array = [0.0,z]
I keep getting:
Error using horzcat Dimensions of matrices being concatenated are not consistent.
What am I missing?

댓글 수: 1

@David Pesetsky: What shape do you expect the output to be, when you concatenate these together horizontally: [1x1,48x1]. The first has one row, the second has 48 rows... how many rows should the output have? How many columns?

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

 채택된 답변

KSSV
KSSV 2018년 6월 13일

0 개 추천

You should join them by using vertcat. Note that your z is row matrix.
z = rand(48,1) ;
array = [0.0 ;z] % method 1
array = vertcat(0,z) % or use vertcat

댓글 수: 2

I used the:
array = [0.0 ;z]
method. I never saw a semicolon used like that. I had a space, and a comma. Both failed.
@David Pesetsky: how to define matrices is explained in the introductory tutorials:
These explain many basic concepts that are invaluable for using MATLAB.

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

추가 답변 (1개)

alfiya riyas
alfiya riyas 2019년 12월 26일

0 개 추천

In a column contains char vaues 'F' and 'M'.
i want to add values again 1 0 -1 in the same column using for loop
no of rows 6106 an the column no is 2
how to add these numbers usinf for ands if loop

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

질문:

2018년 6월 13일

답변:

2019년 12월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by