Help - Problem with fminsearch
Show older comments
Hi everyone,
I have three vectors that I calculated in MatLab with expression find previously.
Now I would create a function that maximize my utility function (U) and retourn me the values find analiticaly.
For this I writed this function:
function U = punto2(x, PC, p_a, p_m, p_s)
%Definiamo i parametri
omega_a = 0.33;
omega_m = 0.33;
omega_s = 0.33;
epsilon = 0.5;
cs_bar = 0;
ca_bar = 0;
cm_bar = 0;
% Dove x(1) = c_m and x(2)= c_s
U = - ( ((omega_a^(1/epsilon)) * ( ((PC/p_a) - ((p_m*x(1))/p_a) - ((p_s*x(2))/p_a)) + ca_bar )^((epsilon-1)/epsilon)...
+ (omega_m^(1/epsilon)) * (x(1) + cm_bar)^((epsilon-1)/epsilon)...
+ (omega_s^(1/epsilon)) * (x(2) + cs_bar)^((epsilon-1)/epsilon) )^(epsilon/(epsilon-1)) );
Where U is the function that i would maximize.
Now, when I call the function in my main script in this way:
z0 = [0.333 0.333];
max_U(t,:) = fminsearch(@(x) punto2(x, PC, p_a, p_m, p_s), z0);
MatLab retourn me different values except for the first.
Info: The function is recalled inside the for loop.
Some help?
Answers (0)
Categories
Find more on Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!