I need to find the answer for the following error and code
Afficher commentaires plus anciens
sum1 = zeros(172,1);
sum2 = 0;
for i = 1:length(data2) % Iterate up to the length of H_BM or g_mean
sum1(i) = P1(i)*(g_p(i)+((g_mean(i).*H_BM(i))*(10)^(-5)));
sum2 = sum2 + P1(i);
%fprintf('Iteration %d: sum1 = %.6f\n', i, sum1(i)); % Print iteration output of sum1
end
xx = sum1;
total = sum(xx)
ssum = sum1.*H_BM;
std_ssum = std(ssum,1);
std_ssum
there is a error when taking the total. "Array indices must be positive integers or logical values." please help me to solve this problem.

4 commentaires
Walter Roberson
le 30 Avr 2024
Chances are that you previously created a variable named sum or std
Prabhath Manuranga
le 30 Avr 2024
Voss
le 30 Avr 2024
clear sum std
Prabhath Manuranga
le 30 Avr 2024
Réponses (0)
Catégories
En savoir plus sur Logical dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!