How do solver a function for multiple values then graph it
Mostrar comentarios más antiguos
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 ?
Respuestas (1)
Star Strider
el 2 de Mzo. de 2016
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 comentarios
Shabib Abu-Jaber
el 2 de Mzo. de 2016
Star Strider
el 2 de Mzo. de 2016
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
el 2 de Mzo. de 2016
Star Strider
el 3 de Mzo. de 2016
That would work. Give it a go!
Categorías
Más información sobre Calculus en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!