how to write the mathlab code for the sigma formula below?

suppose I have a value
Eval (X_1) = 40
Eval (X_2) = 30
Eval (X_3) = 70
Eval (X_4) = 80
Eval (X_5) = 24
Eval (X_6) = 35
Eval (X_7) = 86
Eval (X_8) = 74
Eval (X_9) = 63
Eval (X_10) = 52
F = sigma (Eval (X_ (h))) where h = 1 to h = 10
please help mathlab code for sigma F formula?

4 commentaires

Please, go to MATLAB Onramp and do the tutorial. It will help you immensely to start programming.
Learn how to use vectors. Do not try to create numbered variables like this, as this is a programming style that will only bridge you programming pain.
give me real solution please?

Connectez-vous pour commenter.

Réponses (1)

sum(Eval([X_1, X_2, X_3, X_4, X_5, X_6, X_7, X_8, X_9, X_10]))
this assumes that Eval is a vector, or that Eval is a function that is vectorized.
If Eval is a function that is not vectorized then
sum(arrayfun(@Eval, [X_1, X_2, X_3, X_4, X_5, X_6, X_7, X_8, X_9, X_10]))

4 commentaires

>> uji
745
535
715
505
535
I want to add the values above using the sigma notation?
I use the sum notation or
eg F = sum (eval)
where eval is the value above
please for a solution sir?
op_size = 5;
%sigma=0
%q=0
for count = 1:pop_size
%fprintf('count =%d\n',count);
c = [10 2 20 11
12 7 9 20
4 14 16 18];
[m,n] = size(c);
phi = 1:m*n;
s = [15
25
10
];
d = [5 15 15 15];
for count2=1:length(phi)
% fprintf('count2=%d\n',count2);
used_idx = randi(length(phi));
trial = phi(used_idx);
phi(used_idx) = [];
i = [1+mod((trial-1),m)];
j = [1+mod((trial-1),n)];
x(i,j) = min(s(i),d(j));
s(i) = s(i)-x(i,j);
d(j) = d(j)-x(i,j);
Eval=0;
for j=1:n
for i=1:m
if x(i,j)>0
Eval=Eval+c(i,j)*x(i,j);
%fprintf('Eval=%d\n',Eval);
end
end
end
end
disp(Eval)
end
this is my complete mathlab code, i want to add up the value of eval.
Initialize Eval to 0 before the for count = 1:pop_size statement. This will accumulate all the values added to it in the iterations over count, count2, j, and i.
For whatever reason, the poster has a requirement that they use "sigma" (sum) for this purpose, so incremental addition is not an acceptable solution to them.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Variables dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by