Solving a symbolic equation for a vector

조회 수: 4 (최근 30일)
Hubert Coppieters 't Wallant
Hubert Coppieters 't Wallant 2022년 4월 23일
답변: Paul 2022년 4월 23일
I need the values of r for different t values, this is how I tried to do it:
syms r
syms t
eq = r^2 == r^2*cos(t)^2 + ((283*r^2*cos(t)^2)/50 + (3481*r*cos(t))/2500)^2;
thetas = [0: pi/20: pi/2];
eq1 = subs(eq, t, thetas);
R = solve(eq1, r)

채택된 답변

Paul
Paul 2022년 4월 23일
For each value of theta, there are four solutions, two of which are the trivial zero solution. All solutions can be saved in a cell array and then you can figure out which ones to keep. Or you can choose the solutions you want inside the loop.
syms r
syms t
eq = r^2 == r^2*cos(t)^2 + ((283*r^2*cos(t)^2)/50 + (3481*r*cos(t))/2500)^2;
thetas = sym(pi)*[0: 1/20: 1/2];
for ii = 1:numel(thetas)
R{ii} = solve(subs(eq,t,thetas(ii)),r);
end
% for example
R{2}
ans = 

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Calculus에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by