MATLAB Answers

How to solve this simple system of 2 equation in MATLAB

조회 수: 5(최근 30일)
Abdulaziz Abutunis
Abdulaziz Abutunis 4 May 2018
댓글: John BG 10 May 2018
Hi All;
I wonder if Matlab can solve this two equations to find the Fx and Fy as a function in the other constants. I know I can do it by hand just want to validate. Please see the initial code below
syms D L COST SINT Fx Fy
Fx * COST + Fy *SINT - D =0;
Fx * SINT + Fy * COST -L =0;
solve ( text: the two equations for Fx and Fy)
Thank you for your valuable suggestion
Aziz

  댓글 수: 0

로그인 to comment.

채택된 답변

John BG
John BG 6 May 2018
편집: John BG 6 May 2018
Hi Abdulaziz
syms v Fx Fy D L
b=[D ;L]
b =
D
L
A=[(1-v^2)^.5 v;v (1-v^2)^.5]
A =
[ (1 - v^2)^(1/2), v]
[ v, (1 - v^2)^(1/2)]
F=A\b
=
(D*v^2 - D + L*v*(1 - v^2)^(1/2))/((1 - v^2)^(1/2)*(2*v^2 - 1))
(D*v - L*(1 - v^2)^(1/2))/(2*v^2 - 1)
.
these are the expressions
.
Fx=F(1)
=
(D*v^2 - D + L*v*(1 - v^2)^(1/2))/((1 - v^2)^(1/2)*(2*v^2 - 1))
Fy=F(2)
Fy =
(D*v - L*(1 - v^2)^(1/2))/(2*v^2 - 1)
.
with
v=sin(t)
.
if you find this answer useful would you please be so kind to consider marking my answer as Accepted Answer?
To any other reader, if you find this answer useful please consider clicking on the thumbs-up vote link
thanks in advance for time and attention
John BG

  댓글 수: 0

로그인 to comment.

추가 답변(2개)

Stephan
Stephan 4 May 2018
편집: Stephan 4 May 2018
Hi,
you could do so:
% declare syms
syms D L t;
% Coefficient Matrix
A = [cos(t) sin(t); sin(t) cos(t)];
% RHS
b = [D ; L];
% Unknown: Fx, Fy
F = A\b;
% create Matlab function
fun = matlabFunction(F);
% Test for D = 0, L = -1 and t = pi()
D = 0;
L = -1;
t = pi();
[F] = fun(D, L, t)
this gives you a vector F containing Fx and Fy:
F =
0.0000
1.0000
or you do the same in a live script with symbolic toolbox and get the same result but nice:
Best regards
Stephan

  댓글 수: 4

표시 이전 댓글 수: 1
Jan
Jan 7 May 2018
@Abdulaziz Abutunis: The shown output for F is the x and y component already in dependence to the other variables. So what do you call "not the final result"?
John BG
John BG 7 May 2018
Abdulaziz may not need the anonymous function, just the expressions of the results, have a look at my answer.
Abdulaziz Abutunis
Abdulaziz Abutunis 7 May 2018
That what I meant John. Sorry, Stephan if my question statement was not clear enough.

로그인 to comment.


Abdulaziz Abutunis
Abdulaziz Abutunis 7 May 2018
Thank you John and all of you who have valuable suggestions. John, that was exactly what I want

  댓글 수: 1

John BG
John BG 10 May 2018
Thanks Abdulaziz
feel free to ask me about having a look at any other particular question that you may consider I would be able to assist with.
Regards
John BG

로그인 to comment.

이 질문에 답변하려면 로그인을(를) 수행하십시오.


Translated by