Solving Matrices with multiple variables
8 次查看(过去 30 天)
显示 更早的评论

I am really struggling to work out how to solve this, can anyone help with any suggestions of how to solve this for a beginner?
I have tried to search how to solve but all the videos and tutorials I can find are solving simulatneous equations with only variables in one matrix.
I think I mostly need to know how to input variables within the matrices themselves, this should help me with solving the rest.
0 个评论
回答(1 个)
Walter Roberson
2021-6-24
Example:
M = randn(6,6)
guesses = randn(1,6);
f = @(x) [x(1),0,1,2,x(2),x(3)].' - M*[0;x(4);x(5);x(6);0;0]
fsolve(f, guesses)
2 个评论
Walter Roberson
2021-6-24
The general idea is that when you have sets of equations, you can often rewrite them as sets of zero finding.
L1(x) = R1(x)
L2(x) = R2(x)
can be rewritten as
L1(x) - R1(x) = 0
L2(x) - R2(x) = 0
then you drop the = 0 part and build a vector out of the rest,
[L1(x) - R1(x);
L2(x) - R2(x)]
and wrap it in an anonymous function
F = @(x) [L1(x) - R1(x);
L2(x) - R2(x)]
and now you have a function that you can pass to a numeric root-finder such as fsolve .
fsolve() has several algorithms. Estimates of the jacobian might be used to figure out which direction to go in.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!