Mean between an interval
3 次查看(过去 30 天)
显示 更早的评论
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 ?
采纳的回答
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.
0 个评论
更多回答(1 个)
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!