How can I get a calculated function value???
Mostra commenti meno recenti
I want to calculate Lagrangian fuction.
L(x_wt11, x_wt21, x_wt12, x_wt22) = Vt1 * ( (1-p_wt11)^x_wt11 * (1-p_wt21)^x_wt21 )...
+ Vt2 * ( (1-p_wt12)^x_wt12 * (1-p_wt22)^x_wt22 )...
- lambda1 * ( 1-(x_wt11 + x_wt12))...
- lambda2 * ( 1-(x_wt21 + x_wt22))...
- lambda3 * ( Vw1 * (1-s_wt11/u)^x_wt11 * (1-s_wt12/v)^x_wt12...
+ Vw2 * (1-s_wt21/u)^x_wt21 * (1-s_wt22/v)^x_wt22 - 2 * beta);
When I input L(0,0,0,0) (or L(1,0,0,0), L(0,1,1,0)...etc)
the answer is not calculated value, although I declare all parameters.
In this equation, "x_wt11, x_wt21, x_wt12, x_wt22" are binary variable,
and anothers are parameters(constant).
I declare parameters before this equation except 'u, v'
because 'u,v' are dependent on "x_wt11, x_wt21, x_wt12, x_wt22" value.
In summary,
1. declare parameters. (except 'u,v')
2. declare Lagrangian function.
3. declare parameters 'u, v'
* The reason why I declaring 'u,v' afterwards, I want to prevent deviding by zero.
* u = x_wt11 + x_wt21 , v = x_wt12 + x_wt22
* So, if "x_wt11=0", "x_wt21=0", and then u is zero.
* To solve this problem, I use "if" statement.
if (x_wt11+x_wt21) == 0
u=1;
elseif (x_wt11+x_wt21) == 1
u=1;
elseif (x_wt11+x_wt21) == 2
u=2;
else
u=0;
end
And then, if I input "L(0,0,0,0)"
the answer is like this way, "52/(22*u) + 69/(22*v) + 74/56"
I declare parameters 'u,v' but, Why the answer is not a calculated??? and How I can solve this problem???
Risposta accettata
Più risposte (2)
SaiDileep Kola
il 19 Gen 2021
0 voti
I see no reason why it is not calculated after declaring all values, check if values "u" and "v" are present in the workspace and try to run the equation once again if you see those values are present.
연승 김
il 19 Gen 2021
0 voti
2 Commenti
SaiDileep Kola
il 19 Gen 2021
If possible can you share your code snipped and commands being executed, so that I can reproduce the issue at my end
연승 김
il 26 Gen 2021
Categorie
Scopri di più su Conversion Between Symbolic and Numeric in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!