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

3 ビュー (過去 30 日間)
Prabhath Manuranga
Prabhath Manuranga 2024 年 4 月 30 日
コメント済み: Prabhath Manuranga 2024 年 4 月 30 日
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 件のコメント
Voss
Voss 2024 年 4 月 30 日
clear sum std
Prabhath Manuranga
Prabhath Manuranga 2024 年 4 月 30 日
Thank you.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by