フィルターのクリア

assigning multiple values to symbolic variables from a matrix product

2 ビュー (過去 30 日間)
Brad Patyk
Brad Patyk 2014 年 7 月 30 日
回答済み: Ashish Gudla 2014 年 8 月 5 日
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.

回答 (1 件)

Ashish Gudla
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.

カテゴリ

Help Center および File ExchangeNumber Theory についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by