How to store vectors as parameters in a matrix
3 次查看(过去 30 天)
显示 更早的评论
Hi, I needed help with storing vectors that are passed in my function into a matrix. More specificially, the vectors are of size 4 where
[a1, a2, a3, c]. I wanted to make a 3x3 matrix and a fourth individual vector with the three c (plural)s.
Here is my code:
function [Pspace, Nspace] = a1 (plane1, plane2, plane3);
A = [plane1; plane2; plane3];
Note: I want A to be a 3x3 matrix but each vector passed in has 4 elements!
2 个评论
James Tursa
2019-1-30
You obviously can't stuff 12 elements into 9 elements. Maybe you could describe the larger problem here and what this function output will be used for, and what the inputs are.
回答(1 个)
Eugenio Grabovic
2019-1-30
A = [plane(1:3);plane2(1:3);plane3(1:3)];
b = [plane1(4);plane2(4);plane3(4)];
Now A is 3x3 matrix and b is 3x1 vector.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!