How to solve this simple system of 2 equation in MATLAB
이전 댓글 표시
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
채택된 답변
추가 답변 (2개)
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
Abdulaziz Abutunis
2018년 5월 6일
Jan
2018년 5월 7일
@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
2018년 5월 7일
Abdulaziz may not need the anonymous function, just the expressions of the results, have a look at my answer.
Abdulaziz Abutunis
2018년 5월 7일
Abdulaziz Abutunis
2018년 5월 7일
0 개 추천
댓글 수: 1
John BG
2018년 5월 10일
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
카테고리
도움말 센터 및 File Exchange에서 Code Performance에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!