Problem with parameterized solutions and evalin symengine error

1 view (last 30 days)
I have to plot a graph of the function m(t) and calculate t for m=2, the plot show that m=2 when t~2. That is, m~1.33. But when I use solve, I get parametrized solutions the "answer is on" z13. How i get the solution for the interval 0<=t<=pi/2 ?
clear all
syms a R k cmola m t M raio aux Fs
R = 0.2; a = 0.4; k = 1000;
cmola = [R*sin(t),R*sin(t)-R,-a];
Fs = (((sqrt(sum(cmola.^2)))-a)*k)*[sin(t)*R/(sqrt(sum(cmola.^2))),((cos(t)-1)*R)/(sqrt(sum(cmola.^2))),0];
raio = [R*sin(t),R*cos(t),0];
M = cross(raio,Fs);
t = linspace(0,pi/2);
m = sqrt(sum(M.^2))./(0.2*9.80665)
t = linspace(0,pi/2);
plot(t,subs(m));
ylabel('Angulo theta');
ylabel('Massa m');
grid on;
m=2;
solve(sqrt(sum(M.^2))./(0.2*9.80665)-m,t)
I tried to use evalin(symengine,'numeric::solve(sqrt(sum(M.^2))./(0.2*9.80665)-m, t = 0..(pi/2)') but i get:
??? Error using ==> mupadengine.mupadengine>mupadengine.evalin at 100
MuPAD error Error: 'expression' expected [line 1, col 27]
How can I get JUST one answer and the answer that I want, (that was shown on the graph) on interval 0 to pi/2?

Answers (1)

Christopher Creutzig
Christopher Creutzig on 31 Mar 2014
>> vpasolve(sqrt(sum(M.^2))./(0.2*9.80665)==2,t,[0,pi/2])
ans =
1.3371348850567568969524166439585
Note that this only works if you do not overwrite t with a vector of numbers. I'd strongly suggest to change
t = linspace(0,pi/2);
plot(t,subs(m));
to
tt = linspace(0,pi/2);
plot(tt,subs(m,t,tt));
(You have two places where t is set to a numeric vector.) Also, if you do not redefine m, you can use it as follows:
vpasolve(m==2, t, [0,pi/2])

Community Treasure Hunt

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

Start Hunting!