simultaneous equation when a matrix has multiple sets inside
1 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(1 个)
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
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Quadratic Programming and Cone Programming 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!