Clear Filters
Clear Filters

I need to find the answer for the following error and code

6 views (last 30 days)
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
xx = sum1;
total = sum(xx)
ssum = sum1.*H_BM;
std_ssum = std(ssum,1);
there is a error when taking the total. "Array indices must be positive integers or logical values." please help me to solve this problem.

Sign in to comment.

Answers (0)


Find more on Startup and Shutdown in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!