How do solver a function for multiple values then graph it

So i have a 2 part problem, first i need to solve for theta 1 and theta 2 for the following functions
fl = 4 * cos(thetal) + 2 * cos(thetal + theta2);
f2 = 4 * sin(thetal) + 2 * sin(thetal + theta2);
where F1 = 6 and F2 = values from .1 to 3.6
then i need to graph the values of theta1 and theta2 with my .1 to 3.6 range
I tried doing this but i keep getting a empty graph, how can this be done ?

回答 (1 件)

Star Strider
Star Strider 2016 年 3 月 2 日

0 投票

I would use the Symbolic Math Toolbox:
syms theta1 theta2 f2
Eqn1 = 6 == 4 * cos(theta1) + 2 * cos(theta1 + theta2);
Eqn2 = f2 == 4 * sin(theta1) + 2 * sin(theta1 + theta2);
[th1,th2] = solve(Eqn1, Eqn2, [theta1, theta2]);
th1 =
2*atan((8*f2 + f2^3/(- f2^2 - 32)^(1/2) + (32*f2)/(- f2^2 - 32)^(1/2))/(f2^2 + 96))
-2*atan((f2^3/(- f2^2 - 32)^(1/2) - 8*f2 + (32*f2)/(- f2^2 - 32)^(1/2))/(f2^2 + 96))
th2 =
-2*atan(f2/(- f2^2 - 32)^(1/2))
2*atan(f2/(- f2^2 - 32)^(1/2))

4 件のコメント

Shabib Abu-Jaber
Shabib Abu-Jaber 2016 年 3 月 2 日
And then how do i plot it ?, and they have to both be in the same box
Star Strider
Star Strider 2016 年 3 月 2 日
You create expressions or functions for each of them, remembering to vectorise them, then evaluate them for your values of ‘f2’. Then plot them as functions of your ‘f2’ vector. See the documentation for the plot function to understand how to plot them.
See the documentation for Array vs. Matrix Operations for details on how to write them to evaluate them with your ‘f2’ vector.
Shabib Abu-Jaber
Shabib Abu-Jaber 2016 年 3 月 2 日
And at start (before I enter the equation)I give f2 = linspace(.1,3.6, 35)??
Star Strider
Star Strider 2016 年 3 月 3 日
That would work. Give it a go!

サインインしてコメントする。

カテゴリ

質問済み:

2016 年 3 月 2 日

コメント済み:

2016 年 3 月 3 日

Community Treasure Hunt

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

Start Hunting!

Translated by