Can someone help me to solve the below-mentioned calculation? i have vectors
A1(221X1), D1(221X1) and P(221X1) and my formula to calculate utility is Utility= (((1-P(1,1))*(D(1,1)/(D(1,1)+A1(1,1)))* V)-C + (((1-P(2,1))*(D(2,1)/(D(2,1)+A1(2,1)))* V)-C +………till (((1-P(221,1))*(D(221,1)/(D(221,1)+A1(221,1)))* V)-C
My requirement is:
For iteration 1:
% A1= (221X1) random values
% X1= (221X1) calculated values
% D1= (221X1) random values
% utility1= (((1-P(1,1))*(D(1,1)/(D(1,1)+A1(1,1)))* V)-C + (((1-P(2,1))*(D(2,1)/(D(2,1)+A1(2,1)))* V)-C +………till (((1-P(221,1))*(D(221,1)/(D(221,1)+A1(221,1)))* V)-C%
% store the calculated utilty1 value %
% store the generated A1 vector used in the iteration1 utility calculation %
% store the generated D1 vector used in the iteration1 utility calculation %
% store the calculated P vector used in the iteration1 utility calculation %
start the iteration 2
% Do the same as iteration1 and save all newly generated D1, A1, and P %
%Repeat for 1000 iteration and store the newly generated A1, D1, P vector of size (221X1) and utility of size (1) for 1000 iterations %
%Find the maximum utility of 1000 iteration and show the corresponding D1, P and A1 vectors used in the calculation of that maximum utility%
V= 0.2;C=0.2;I= eye(221);s = string({'CR';'E';'R';'S';'SR'})s1 = s([2,5])' + (1:20)'s1 = [s([2,3,2,4]) + [101;1;106;1];s1(:)] + (0:4)d = {tril(ones(44,4),-1),diag(ones(20,1),-24)}d{2} = d{2}(:,1:end-4)dd = repmat({[d{:}]},1,5)str = cellstr([s(1);s1(:)])out = [{nan},str(:)';str, num2cell([zeros(1,221);[ones(220,1),blkdiag(dd{:})]]) ];A= out(2:end,2:end);for i=1:1000A1= ( randn(221,1) * 0.1 ) + 0.45;X11= cell2mat(A)*A1;P= zeros(221,1);P(:)= X11(:)/sum(X11)D1= ( randn(221,1) * 0.1 ) + 0.45;% Utility= (((1-P(1,1))*(D(1,1)/(D(1,1)+A1(1,1)))* V)-C + (((1-P(2,1))*(D(2,1)/(D(2,1)+A1(2,1)))* V)-C +.........till (((1-P(221,1))*(D(221,1)/(D(221,1)+A1(221,1)))* V)-C
end %
Best Answer