How do i get matlab to solve this equation in terms of b?

1 Ansicht (letzte 30 Tage)
I want to input various values for Pcw and find out what value b would have but I can't seem to get it to work! Help!
Nlayers=20;
TLC=6.81;
Vad=0.15;
a=100*10.^-6;
syms b;
r=(a.^2+b.^2)/(2*b);
Nalvtot=375000000;
Nalvz=Nalvtot/Nlayers;
Valvz=(1/3)*pi*(b.^2)*(3*r-b);
Vair=Vad+Nalvz*Valvz*20;
Pcw=0.071-(log(((0.95/((Vair/Valvmax)-0.22))-1)*0.58))
  1 Kommentar
John D'Errico
John D'Errico am 31 Mär. 2015
Part of your problem might be this...
Pcw=0.071-(log(((0.95/((Vair/Valvmax)-0.22))-1)*0.58))
Undefined function or variable 'Valvmax'.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Star Strider
Star Strider am 31 Mär. 2015
I managed to find ‘Valvmax’ in one of your other posts, and added it to this function:
function Pcw = Lungs(b)
Nlayers=20;
TLC=6.81;
Vad=0.15;
a=100*10.^-6;
r=(a.^2+b.^2)./(2*b);
Nalvtot=375000000;
Nalvz=Nalvtot/Nlayers;
Valvz=(1/3)*pi*(b.^2).*(3*r-b);
Vair=Vad+Nalvz*Valvz*20;
Valvmax=(TLC-Vad)/Nalvtot; %maximum volume
Pcw=0.071-(log(((0.95./((Vair./Valvmax)-0.22))-1)*0.58))
end
The only alternative I can think of to solving your equations for ‘b’ (that I have no desire to do) is to set a value for ‘Pcw’ and then solve for ‘b’ with fzero.
Save this function to its own file as ‘Lungs.m’ (or whatever you choose to call it, but be sure that the function name and file name are the same), then provide a valid value for ‘Pcw’ and your initial estimate or range for ‘b’ (I used [1 10] here) and use this to find ‘b’:
B = fzero(@(b) (Lungs(b) - Pcw), [1 10])
I could not get good (that is not complex) values for ‘B’, but then I don’t know what either ‘Pcw’ or ‘b’ are supposed to be.
  2 Kommentare
sophie webster
sophie webster am 1 Apr. 2015
Thank you so much Star Strider, you've been super helpful! This project of mine is proving to be a bit of nightmare for a matlab novice!
Star Strider
Star Strider am 1 Apr. 2015
My pleasure!
I can well understand that something this complicated would be difficult even for someone with some experience in programming. I don’t understand exactly what you’re doing, but as a physician (internist) and biomedical engineer myself, I’m interested in your project.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Interpolation finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by