I am new to MATLAB and have been assigned to do some problems, here is the one I am stuck on. Firstly I have been given some vectors that I have to find the rectangular form of and secondly I then have to find the magnitude of the two of the vectors. Here is the code I have come up with so far
syms F1 F2
Force = 125;
Theta1 = -90;
Theta2 = 180;
Theta3 = 41.7;
Fwx = Force*cosd(Theta1);
Fwy = Force*sind(Theta1);
F1x = cosd(Theta2)*F1;
F1y = sind(Theta2)*F1;
F2x = cosd(Theta3)*F2;
F2y = sind(Theta3)*F2;
vFw = Fwx+Fwy*j
vF1 = F1x+F1y*j
vF2 = F2x+F2y*j
solve(Fwy+F1y+F2y == 0,F2)
solve(Fwx+F1x+F2x == 0,F1)
It works out in the end almost, however there are a few issues and they most relate to the F2 components. In the vF2 it gives me the correct answer, but in an arbitraily large fraction that though correct I do not believe is satisfactory. In the solve for the F2 the same issue arises, a large fraction that is technically correct. The last thing I am having an issue with is that solve for F1 requires the answer from solve for F2 in order to be solved completely, but once again it appears that it will give me a really large fraction. Any and all help would be great.

 Accepted Answer

To make them not be fractions, use vpasolve or vpa on the result:
F2s = vpasolve(Fwy+F1y+F2y == 0,F2)
F1s = vpasolve(Fwx+F1x+F2x == 0,F1)
.

4 Comments

Thanks you that fixed it up a whole lot. Now on my final answer, the solve for F1, I get a decimal*F2, which if you put it into a calculator with the result of F2 it is correct. Anyway I can bring the result of the solve for F2 into that answer? Maybe a substitution but I am not too sure.
My pleasure!
Substitution is definitely the way to go:
F2s = vpasolve(Fwy+F1y+F2y == 0,F2)
F1s = vpasolve(Fwx+F1x+F2x == 0,F1)
F1s_full = subs(F1s,F2,F2s)
producing:
F2s =
187.90483495742954219540652854913
F1s =
0.74663818228539136079291438363725*F2
F1s_full =
140.29692441525165732593942477091
As requested!
Thank you very much. That cleared up mu confusion about the substitution function as well.
As always, my pleasure!
Thank you!

Sign in to comment.

More Answers (0)

Categories

Find more on Mathematics in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!