Solving a symbolic equation for a vector

3 views (last 30 days)
Hubert Coppieters 't Wallant
Answered: Paul on 23 Apr 2022
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)

Accepted Answer

Paul
Paul on 23 Apr 2022
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 = 

More Answers (0)

Community Treasure Hunt

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

Start Hunting!