MATLAB: Retrieve a variable from a function

functionretrieveSymbolic Math Toolboxvariable

Hi,
I have tried the following:
syms p(n,m,b,d,t)
p(n,m,b,d,t)=((n-m)*((1/b)-(1/d)+ ((n-m)*t)/(n*b*d)))
I know the values of everything in this equation (including the total value of the p function) except n,. How do i get matlab to calculate what n is?
Thank you dearly in advance, Karen

Best Answer

syms p n m b d t
eqn = p == ((n-m)*((1/b)-(1/d)+ ((n-m)*t)/(n*b*d)));
solve_for_n = solve(eqn,n)
% Specify your known values here
m = 3;
b = 2;
d = 1;
t = 2;
p = 12;
the_n_is = vpa(subs(solve_for_n))
Related Question