Error using Zeros, size input must be integers.

6 ビュー (過去 30 日間)
Hazhan Majeed
Hazhan Majeed 2021 年 3 月 17 日
コメント済み: Hazhan Majeed 2021 年 3 月 17 日
Hi
I get this message (error using zeros, size input bust be integers ) when running this code. anyone knows how to fix this ?
Qd=zeros(size(Q,1)/24,length(A));
for i=1:length(A)
for d=1:size(Q,1)/24
bk=Q(1+24*(d-1):24*d,i);
k=~isnan(bk);
Qd(d,i)=sum(bk(k))/length(k);
end
end
thanks

採用された回答

KSSV
KSSV 2021 年 3 月 17 日
編集済み: KSSV 2021 年 3 月 17 日
Qd=zeros(round(size(Q,1)/24),length(A));
for i=1:length(A)
for d=1:round(size(Q,1)/24)
bk=Q(1+24*(d-1):24*d,i);
k=~isnan(bk);
Qd(d,i)=sum(bk(k))/length(k);
end
end
The indices of matrices in MATLAB should be poittive integers.. when you are using size(Q,1)/24, if size(Q,1) is not multiple of 24 you will get a fraction and it will throuw error. So using round will round the number into nearest integer.
  1 件のコメント
Hazhan Majeed
Hazhan Majeed 2021 年 3 月 17 日
thanks, it worked

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMultidimensional Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by