I need a help on making the number calculation into matrix calculation

1 visualización (últimos 30 días)
clc;
clear all;
Profit_S_B = [];
Profit_S_Q = [];
Profit_S_R =[];
Q1 = 100;
q_01 = 50;
P_r = 400;
c = 20;
g = 50;
x = norminv(g/(g+c),100,30);
theta = 0.8351;
Ps_B = ((1-theta)*P_r*g+P_r*c-c*c)/(g+c);
Ps_Q = (P_r*c-c*c)/(g+c);
Ps_R = (theta*P_r*c-c*c)/(g+c);
D =150; % Here if I want change D into For D =1:1:300
S_N0 = min(x,D);
I_N0 = max(0,(D-x));
S_L0 = min((D-S_N0),(Q1+q_01-x));
I_L0 = max(0,(D-Q1-q_01));
Profit_S_B = Ps_B*x + (1-theta)*P_r*S_N0 + (P_r-c)*S_L0 - I_L0*g-(1-theta)*P_r*x
Profit_S_Q =Ps_Q*x + (P_r-c).*S_L0-I_L0*g
Profit_S_R =Ps_R*x+(1-theta)*P_r*S_N0+(P_r-c).*S_L0-I_L0*g
Here If I want Change D = 150 to For D = 1:1:300, How should I change the folloing code?

Respuesta aceptada

Ameer Hamza
Ameer Hamza el 19 de Oct. de 2020
clc;
clear all;
Profit_S_B = [];
Profit_S_Q = [];
Profit_S_R =[];
Q1 = 100;
q_01 = 50;
P_r = 400;
c = 20;
g = 50;
x = norminv(g/(g+c),100,30);
theta = 0.8351;
Ps_B = ((1-theta)*P_r*g+P_r*c-c*c)/(g+c);
Ps_Q = (P_r*c-c*c)/(g+c);
Ps_R = (theta*P_r*c-c*c)/(g+c);
D = 1:300;
S_N0 = zeros(size(D));
I_N0 = zeros(size(D));
S_L0 = zeros(size(D));
I_L0 = zeros(size(D));
Profit_S_B = zeros(size(D));
Profit_S_Q = zeros(size(D));
Profit_S_R = zeros(size(D));
for i = 1:numel(D)
S_N0(i) = min(x,D(i));
I_N0(i) = max(0,(D(i)-x));
S_L0(i) = min((D(i)-S_N0(i)),(Q1+q_01-x));
I_L0(i) = max(0,(D(i)-Q1-q_01));
Profit_S_B(i) = Ps_B*x + (1-theta)*P_r*S_N0(i) + (P_r-c)*S_L0(i) - I_L0(i)*g-(1-theta)*P_r*x;
Profit_S_Q(i) =Ps_Q*x + (P_r-c).*S_L0(i)-I_L0(i)*g;
Profit_S_R(i) =Ps_R*x+(1-theta)*P_r*S_N0(i)+(P_r-c).*S_L0(i)-I_L0(i)*g;
end

Más respuestas (0)

Categorías

Más información sobre String Parsing en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by