assigning multiple values to symbolic variables from a matrix product
2 次查看(过去 30 天)
显示 更早的评论
I am using Kramer's rule to use a product of matrices to produce 2 values. How do I initialize these 2 values to symbolic variables? For example I've tried
(a,b)=inv(A)*B
where A and B and the matrices. I want a to equal the first solution and b to equal the second solution. A is 2X2, B is 1X2.
Any help is appreciated.
0 个评论
回答(1 个)
Ashish Gudla
2014-8-5
I dont believe there is a way to directly assign a vector to a comma separated list.
If you are just working with 2 variables the easiest way would be
C = inv(A)*B;
a=C(1);
b=C(2);
clear C; % so that you can free up the memory
You can however use comma separated list if you have a cell array.
C = inv(A)*B;
D = num2cell(C);
[a,b] = D{:};
clear C;
clear D;
Hope that helps.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Symbolic Math Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!