Hello,
I would like to solve the following equation:
eqn = Ff == Kff*uf + Kfs*us; % I want to solve for uf knowing that
Kff =
3.0240 0.7680
0.7680 3.2427
Kfs =
0 0 -1.0240 -0.7680 -2.0000 0
0 -2.6667 -0.7680 -0.5760 0 0
Ff =
0
0
us =
0
-25
0
0
0
0
The problem is that I'm getting an error from MATLAB saying that uf is not defined, uf is supposed to be a 2x1 matrix but I want to solve for it. How can I do that?

 채택된 답변

Star Strider
Star Strider 2018년 11월 21일
편집: Star Strider 2018년 11월 22일

0 개 추천

Straightforward:
KFF = Kff \ -(Kfs*us)
KFF =
5.5556
-21.8750
Another option is to use fsolve:
[UF, fval] = fsolve(@(uf) Kff*uf + Kfs*us, [1; 1])
UF =
5.5556
-21.8750
fval =
-7.1054e-015
-14.2109e-015

댓글 수: 5

Hazem El Sankari
Hazem El Sankari 2018년 11월 21일
Thank you!
But what does [1; 1] refer to at the end of the function?
Hazem El Sankari
Hazem El Sankari 2018년 11월 21일
편집: Hazem El Sankari 2018년 11월 21일
Also, what Ff was, say, [100 ; 200]?
How can the equation be adjusted as then?
Star Strider
Star Strider 2018년 11월 21일
편집: Star Strider 2018년 11월 22일
My pleasure.
But what does [1; 1] refer to at the end of the function?
The ‘[1;1]’ is an initial parameter estimate. The fsolve function needs to have an initial guess at the value to solve for.
Also, what Ff was, say, [100 ; 200]?
Ff = [100; 200]
[UF, fval] = fsolve(@(uf) Kff*uf + Kfs*us - Ff, [1; 1])
Kfsus = Kfs*us;
UF = Kff \ -((Kfs*us) - Ff)
yield respectively:
UF =
24.0742
35.4160
fval =
0
0
UF =
24.0742
35.4160
Hazem El Sankari
Hazem El Sankari 2018년 11월 21일
Thanks again for your quick and helpful reply!
Star Strider
Star Strider 2018년 11월 21일
My pleasure.
If my Answer helped you solve your problem, please Accept it!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

질문:

2018년 11월 21일

편집:

2018년 11월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by