What is the matrix code for column vectors

조회 수: 3 (최근 30일)
Meenakshi S
Meenakshi S 2017년 7월 14일
편집: Jan 2017년 7월 14일
You have two variables u, v and you calculate the shape using the size command:
>> size(u) ans = 1 3 >> size(v) ans = 3 1 I want a matrix with 3 columns, the vectors u and v in the first two, and their sum in the third.

답변 (2개)

dbmn
dbmn 2017년 7월 14일
This should do the trick using the ' for transpose
new_matrix = [u', v', (u+v)']
  댓글 수: 2
Meenakshi S
Meenakshi S 2017년 7월 14일
It does not accept this.Can u pls tel any other command
Jan
Jan 2017년 7월 14일
@Meenakshi S: Please do not let us guess. Does "not accept" means, that you get an error message? If so, please post it here. It is much easier to fix an error than to guess, what the error is.
Many readers of the forum are not native English speakers. Then kewl abbrevs makes it harder to read your messages.

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


C.J. Harris
C.J. Harris 2017년 7월 14일
There are a few ways to do this, for example:
x = [u' v (u' + v)]
The apostrophe can be used to transpose a matrix. You could also use the 'reshape' command.
  댓글 수: 2
Meenakshi S
Meenakshi S 2017년 7월 14일
It does not accept this.Can u pls tel any other command
Jan
Jan 2017년 7월 14일
편집: Jan 2017년 7월 14일
This is a correct answer. Because I assume, that this is a homework question, I recommend not to post the solution, because then the OP cannot submit this as his solution anymore. It is better to ask, what she has tried so far and which problems occur.

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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by