I've got 2 files the first file with a line (1) calls the file (2).
(1) P0=fzero(@(P0) estimateSurfacePressure(P0,false,extPar), [1 25])
(2) function [Ps,Rs]=estimateSurfacePressure(P0,isCompressed,extPar)
So what I know is a value for P0 is chosen between 1 and 25 and then the program will stop when a proper Ps is zero. (There's an fzero inside the 2nd file) what I don't understand is that since at the very last line it says P0 = Ps (so when the program runs P0 chosen by (1) was altered). Then after several times varying P0 in order to find Ps = 0 once it's found when the program comes back to the previous file where the line (1) is. What P0 is is actually the value chosen firstly in order to find Ps = 0 and not the value Ps itself. I thought P0 should be Ps because it's established at the botton of the file (2) P0 = Ps. How come does that happen?
Best Answer