How to turn assigned vectors into a 3x3 matrix?

25 次查看(过去 30 天)
How do I turn these vectors into a 3x3 matrix? I am new at MATLab, so any help would be appreciated!
vec1 = [1,2,4]
vec2 = [5,6,8]
vec3 = 1:2:11

回答(1 个)

James Tursa
James Tursa 2019-9-20
编辑:James Tursa 2019-9-20
Assuming vec3 is a typo,
result = [vec1;vec2;vec3];
If you need to, you can transpose the result.
If your vec3 is not a typo, then you have too many elements in vec3 to make it part of the 3x3 matrix.
  2 个评论
Anne Nguyen
Anne Nguyen 2019-9-20
I was supposed to use a column operator for vec3 for 1,3,5,7,9,11, so that is why I did it like that. Is there any way I can create a matrix with vec3 being a column operator also?
James Tursa
James Tursa 2019-9-20
Think about it. vec1 has three elements, vec2 has three elements, and vec3 as written has six elements. How can you fit all of those into a 3x3 matrix? What is the actual wording of the assignment?

请先登录,再进行评论。

类别

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