Solving an equation where 2 variables are dependant through a table

Hi. I have a simple equation: rho = M/ V/ (1-P*k)
M, V and k are known constants.
neither rho nor P are known but rho is a function of P, and there's a table where for each value of P a coresponding value of rho is specified.
how do I find the P and rho that solve the eqaution?
Thanks

 Réponse acceptée

Matt J
Matt J le 5 Déc 2021
Modifié(e) : Matt J le 5 Déc 2021
If T is your table,
rho=@(Pq) interp1(T.P,T.rho,Pq);
P=fminsearch(@(P) norm( rho(P) - M/ V/ (1-P*k) ), P0 ) ;
rho=rho(P)

2 commentaires

Yuri Katz's reply moved here:
works like a charm, thanks Matt
You're quite welcome.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Mathematics dans Centre d'aide et File Exchange

Produits

Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by