Convert array initialization code

I am trying to convert some sample Matlab code I found to another language for implementing in some custom software. I do not have Matlab and am brand new to its syntax. Can anyone help translate what kind of an array/matrix the below is creating?
v = [x y z]
[row col] = size(v);
v2 = [zeros(row, 1) v]
It seems like it would be creating a 2D array with the first row being all zeros and the second being the vector v; however, I don't know if that makes sense for how it is being used. Can anyone confirm what the value of v2 would be?

댓글 수: 1

Star Strider
Star Strider 2015년 9월 9일
‘...first row being all zero...’
No. The first column is all zeros, with its row length defined by whatever the value of ‘row’ is. If row=1, it’s a scalar.

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

답변 (1개)

Thorsten
Thorsten 2015년 9월 9일

0 개 추천

You're right, the code adds a zero in front of vector v or a zero column if v is a matrix.

댓글 수: 1

Jon Wynveen
Jon Wynveen 2015년 9월 9일
So if x, y, and z are scalar values, then v2 would be [0 x y z], correct?

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

카테고리

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

태그

질문:

2015년 9월 9일

댓글:

2015년 9월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by