Array Manipulation - Substituting matrices with vectors

조회 수: 4 (최근 30일)
Dillon Hudson
Dillon Hudson 2011년 9월 6일
Hi all,
I am having trouble with array subscripts in MATLAB.
Say we have a matrix "M=pascal(9)"
I want to "use array subscripting" to assign the 4th column of M to a new vector named V.
This is my code:
M = pascal(10);
syms v
M(:,3) = v
I have looked everywhere on the internet and can't find any help. Thanks in advance

채택된 답변

Oleg Komarov
Oleg Komarov 2011년 9월 6일
The LHS is always the assigned value in MATLAB, i.e. you cannot assign something that do not exist yet:
v = M(:,4)
Are you using syms for any specific reason?
  댓글 수: 1
Dillon Hudson
Dillon Hudson 2011년 9월 6일
Not using syms for any reason other than I don't know what I'm doing :P
And I got it working, thanks a lot!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by