Filter löschen
Filter löschen

Problem with equations solver

1 Ansicht (letzte 30 Tage)
Carlo Pezzoli
Carlo Pezzoli am 18 Jul. 2018
Hi all, I've got a problem with the equations solver. I'm sure that my code is wrong (in the function "solve") because I've used symbolic functions, but I don't know where is the mistake.
e
syms alpha(t) beta(t) c(t)
eqns = [(a*cos(alpha))+(b*cos(beta))==0 , (a*sin(alpha))+(b*sin(beta))==c];
sol = solve(eqns, [c, beta]);
ALPHA=0:pi/100:4*pi;
plot(ALPHA, subs(sol.c(2,1), alpha(t) ,ALPHA))
eqns_dot=diff(eqns, t)

Antworten (1)

Areej Varamban Kallan
Areej Varamban Kallan am 2 Aug. 2018
Hi Carlo,
I understand that you are having issues when using the 'solve' function to solve symbolic equations.
When solving symbolic equations using 'solve(eqn,vars)', 'vars' should be an array of symbolic variables and not symbolic functions. Moreover when using 'plot(x,y)', 'x' and 'y' must be numeric, datetime, duration or an array convertible to double. Here I assume a = 2 and b = 3 and substitute these in sol.c when plotting.
syms a b c alpha(t) beta
eqns = [(a*cos(alpha))+(b*cos(beta))==0 , (a*sin(alpha))+(b*sin(beta))==c];
sol = solve(eqns, [c, beta]);
ALPHA=0:pi/100:4*pi;
plot(ALPHA, subs(sol.c(2,1), {alpha(t) ,a,b},{ALPHA,2,3}));
eqns_dot=diff(eqns, t);

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by