MATLAB Answers

0

How do I write this equation in Matlab?

Asked by Steven Zakirov on 18 Apr 2019
Latest activity Answered by Walter Roberson
on 19 Apr 2019
How do I write the equation V in the pdf as a MATLAB equation. I am messing up somewhere and I appreciate any help I can get.
Here is my code ,
syms
p = 1000;
L = 10;
a = 5;
B = 10;
W = 100000;
V_w = a*L*B+(((L^2)*B)/2);
V = B*(L*cos(x)*a+((L^2).*cos(x).*sin(x))/2+((L*cos(x))^2)/2);
theta_max = solve(V/V_w < 1 ,x);

  0 Comments

Sign in to comment.

2 Answers

Answer by Star Strider
on 19 Apr 2019

You need to add ‘x’ to your syms call:
syms x
then with this solve call:
theta_max = solve(V/V_w ,x)
you get:
theta_max =
pi/2
pi

  2 Comments

It would not be solve(v/V_w, x) as that would be solve(v/V_w == 0,x) rather than solve(v/V_w < 1,x)
When I ran it with the inequality, that produces an empty result, no solution.

Sign in to comment.


Answer by Walter Roberson
on 19 Apr 2019

There is a trick to solving inequalities: convert them to equalities.
P/R < 1 implies P < R implies P + dP == R for some positive dP. That is, if you had to add something positive to P to get R, then it implies that P is strictly less than R.
(P+dP)==R implies P/R + dP/R == 1, which implies P/R == 1 - dP/R . So particular dP answers the question of how much less than one P/R is, proportional to R.
Q = @(v) sym(v,'r');
syms x %do not use syms x real, it will not find solutions
p = Q(1000);
L = Q(10);
a = Q(5);
B = Q(10);
W = Q(100000);
V_w = a*L*B+(((L^2)*B)/2);
V = B*(L*cos(x)*a+((L^2).*cos(x).*sin(x))/2+((L*cos(x))^2)/2);
syms dV
theta_max = solve(V + dV == V_w, x, 'MaxDegree', 4);
theta_maxt = simplify( rewrite(theta_max, 'atan') );
The result you get out in theta_maxt will be a series of four long expressions involving atan. Each one of them answers the question of "What would the x have to be for V + dP to exactly equal V_w ?". Or in terms of the constants, "Given an exact amount less than 1000, what would x be for V to be exactly 1000 minus that amount?"
Now, depending on the difference from 1000 that you choose, some of the four theta_maxt might be imaginary. They involved roots of a quartic (degree 4 polynomial), so either 0, 2, or 4 of the solutions will be real valued. There are breakpoints at approximately dV = 839 point something, 1000 exactly, and 1361 point something (yes, there are solutions where x is negative.) The range between 839 and 1000 has four real-valued solutions.
When I put the original inequality to Maple as an inequality, Maple responds with four solutions, all involving arctan() of a particular constant, which I will call C for the moment. They are (arctan(C)-4*pi, 2*pi) exclusive, arctan(C)-2*pi,0) exclusive, (arctan(C),2*pi) exclusive, and (arctan(C)+2*pi,4*pi). The arctan(C) value is approximately 0.57 .

  0 Comments

Sign in to comment.