필터 지우기
필터 지우기

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 CenterFile Exchange에서 Number Theory에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by