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
2016년 3월 2일
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
2016년 3월 2일
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
2016년 3월 2일
Star Strider
2016년 3월 3일
That would work. Give it a go!
카테고리
도움말 센터 및 File Exchange에서 Calculus에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!