I need to find the answer for the following error and code
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 = %.6fn’, 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.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 = %.6fn’, 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. 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 = %.6fn’, 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. array indices logical values. MATLAB Answers — New Questions