The problem is as follows:
Demand and supply in a given market interact in a way that we have three possible equilibrium prices (ptstar) for rt.
u= @(ptstar,rt) (ptstar.^(-1/9) + 2 + rt.* ptstar.^(-1) - ptstar.^(-8/9)) - (2+rt);
Above, you can see the equation which sets demand and supply equal by subtracting supply(2+rt) from demand and solving for zero.
The thing is there are 50 different time periods rt and I need to find the three equilibrium prices for each period(so a total of 150).
After this process, I need to select one value for ptstar of the three possible ones by setting equal probabilities to the maximum(first) and minimum(third) value of the equilibrium price.
Here is my approach( I have no idea how to handle the part with selecting one value for ptstar):
rt = rbar+et
u= @(ptstar,i) (ptstar.^(-1/9) + 2 + i .* ptstar.^(-1) - ptstar.^(-8/9)) - (2+i);
rt is a column vector of 50 numbers following a random distribution with mean 0 and standard dev.6*10^-3 plus 0.77.
Sometimes I get a result, however, the ptstarMax values comein ascending order which makes no sense, because the values of rt are random and in no particular order..
I suspect there is a problem with the linspace function looping rt(1) to rt(50) through each fzero function
Finnaly, sometimes this gets printed: However, sometimes it doesn't appear:
Error using fzero (line 290)
The function values at the interval endpoints must differ in sign.
Error in try2 (line 12)
I really appreciate the help! Thanks a lot!