Retrieve a variable from a function

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

 Accepted 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))

1 Comment

That s great. Thank you so much for your help! Def learned from your answer. Thank you!!!

Sign in to comment.

More Answers (0)

Products

Release

R2018a

Community Treasure Hunt

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

Start Hunting!