Problem with equations solver
조회 수: 1 (최근 30일)
이전 댓글 표시
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)
댓글 수: 0
답변 (1개)
Areej Varamban Kallan
2018년 8월 2일
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);
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Calculus에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!