Solve with multiple values
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Below is the equation I'm trying to work with. g is a single value. vbprime, newtheta and y1 are 1x51 matrices. I just want to solve for t1, for use in c, but I can't seem to get it to solve. I keep getting an error about MUPAD engine in the solve line. I have declared t1 to by sym also. I expect c to S to have multiple values, as well as c. Any thoughts?
S=-0.5*g.*t1^2+vbprime.*sind(newtheta).*t1+y1
solve(S)
c=(100-vbprime.*cosd(newtheta).*t1)
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 22 Okt. 2011
syms t1 vbprime_ newtheta_ y1_
S=-0.5*g.*t1^2+vbprime_.*sind(newtheta_).*t1+y1_;
T1 = solve(S,t1);
T1Fun = matlabFunction(T1, vbprime_, newtheta_, y1_);
c = arrayfun(@(IDX) 100-vbprime(IDX).*cosd(newtheta(IDX)) .* T1Fun(vbprime(IDX), newtheta(IDX), y1(IDX)), 1:length(vbprime));
5 Kommentare
Walter Roberson
am 23 Okt. 2011
Hmmm... the function is a quadratic, so there are two solutions coming out of solve(). Possibly matlabFunction is interpreting that as requiring two output arguments.
Unfortunately as I do not have the toolbox, this is not something I can test for myself.
I would suggest that you would be better off solving the quadratic algebraically once (using the quadratic formula) on paper, and either choosing one of the two roots based upon additional information, or else creating both formula and handling them semi-independently.
For both together, I get
t3 = sin(newtheta .* pi / 180);
t4 = vbprime .* t3;
t5 = vbprime .^ 2;
t6 = t3 .^ 2;
t11 = sqrt(t5 .* t6 + (2 .* g .* y1));
t13 = 1 ./ g;
s1 = (t4 + t11) .* t13;
s2 = (t4 - t11) .* t13;
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!