simultaneous equation when a matrix has multiple sets inside

1 回表示 (過去 30 日間)
Rohan Sharma
Rohan Sharma 2021 年 9 月 12 日
回答済み: Navya Singam 2021 年 10 月 27 日
Hello,
I wanted to solve the simultaneous equation A=rand(3,3,51) and B=rand(3,1,51). I was trying to use the normal method C=A\B but this doesnt work. Was there a method to solve the 51 simultaneous equation using a function or loop as within A and B there are set of 51simultaneous equation.
Thanks
Rohan

回答 (1 件)

Navya Singam
Navya Singam 2021 年 10 月 27 日
Hi Rohan,
for loop can be used to solve this question.
for i=1:51 %% as there are 51 sets of simultaneous equations
sol = mldivide(A(:,:,i),B(:,:,i)); %% alternatively it can be written as A(:,:,i)\B(:,:,i)
%% x = A\B is an alternative way to execute x = mldivide(A,B)
disp("The solution for " +i+"th simultaneous equation is ")
disp(sol)
end
Refer to the mldivide documentation for more information on mldivide.

カテゴリ

Help Center および File ExchangeQuadratic Programming and Cone Programming についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by