matrix operatios to convert two vectors into a matrix
1 次查看(过去 30 天)
显示 更早的评论
Hello, is it possible to obtain a matrix as follows. X and Y are the input vectors required to change into a matrix..
X=[2 Y=[5 3 1 2 4]-1*5 vector
4
5
3
1]-5*1 vector
both the vectors have the index values as elements....now i want to have a 5*5 matrix which is as follows
Z= (2,5) (2,3) (2,1) (2,2) (2,4)
(4,5) (4,3) (4,1) (4,2) (4,4)
(5,5) (5,3) (5,1) (5,2) (5,4)
(3,5) (3,3) (3,1) (3,2) (3,4)
(1,5) (1,3) (1,1) (1,2) (1,4)
Z-5*5 matrix
is it possible to obtain a matrix like this using matlab...pls help....i have no idea how to do this....thanks in advance...
2 个评论
Matt J
2014-8-20
Your Z is not a matrix because its entries are not scalars. There is no MATLAB data type that will efficiently hold large arrays of non-scalar data. You should look for an approach which doesn't require X and Y to be combined into a single array.
Adam
2014-8-20
Despite my potential solution below I would agree with Matt J on the whole though on considering whether you really need this in one matrix.
Possibly you could simply work with the intermediate meshgrid results.
Cell arrays are good for allowing you to store arbitrary things in a matrix form, but their efficiency is not great if you need speed and large amounts of data.
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!