Mean between an interval

1 回表示 (過去 30 日間)
FG
FG 2020 年 10 月 8 日
コメント済み: FG 2020 年 10 月 8 日
I want to calculate the mean between a time interval that depends on a variable like P ;
F=[1 10 2 4 6 8];
for q=1:length(F);
P=F(q);
Average=mean(M3(90000-P*0.2*1732:90000));
'' Integer operands are required for colon operator when used as index'' warning is come.. What is the problem here ?
  1 件のコメント
FG
FG 2020 年 10 月 8 日
and how to solve it ?

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

採用された回答

KSSV
KSSV 2020 年 10 月 8 日
idx = round(90000-P*0.2*1732:90000) ;
Average=mean(M3(idx));
Your indices are not integers.....you got some fractions also.....so use round.

その他の回答 (1 件)

madhan ravi
madhan ravi 2020 年 10 月 8 日
x = 1:5;
x(.2) % error
x(2) % no error , index can only be integers not decimals
I suggest you to do MATLAB Onramp course.
  1 件のコメント
FG
FG 2020 年 10 月 8 日
OK, I will Madhan..

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

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

タグ

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by