MATLAB: I would like to understand how to solve this equation with the unknown “a”. I admit I’m not an expert with the solve function. I followed the online directions but I continue to receive this error, Someone can help me? Thank you!

solvesyms

syms a j mu D R_earth k pi J_2
eqn= j*abs(-2*pi*(2*pi*(a^3/mu)^1/2)/D-(3*pi*J_2*R_earth^2*cos(i))/(a^2*(1-e^2)^2))==k*2*pi;
a(w+1)=solve(eqn,a)
Unable to perform assignment because the left and right sides have a different number of elements.
Error in sym/privsubsasgn (line 1096)
L_tilde2 = builtin('subsasgn',L_tilde,struct('type','()','subs',{varargin}),R_tilde);
Error in sym/subsasgn (line 933)
C = privsubsasgn(L,R,inds{:});
Error in part2 (line 37)
a(w+1)=solve(eqn,a)

Best Answer

e is undefined.
In cos(i) is that intentionally cos(1i) -- cos of the imaginary unit?
We do not know what w is for this purpose.
But imagine that w is a scalar. Then the left side of the assignment would designate space for exactly one output. But is the result of solve() exactly one value?
No! the result of solve() is 5 values. It turns out to be the 5 different roots of a quintic.
Note, by the way, that you are assigning a(w+1) where you just solved for symbolic variable a. There does not seem to be a good reason to do that. Assign to a different variable. If you need the value for a later, then
subs(EXPRESSION, a, solutions_for_a)
Related Question