how to vary data length in the given code.There are 7 sites an each site having different data length.For example n1=18, n2=29 and so on N=number of sites are 7.

1 回表示 (過去 30 日間)
for i=1:500
for j=1:7
b0(j,:,i)=D(j,:,i)/46;
for k=1:45
b1(j,k,i)=(D(j,k,i)*(46-k))/(46*45);
for m= 1:44
b2(j,m,i)=(D(j,m,i)*(46-m)*(46-m-1))/(46*45*44);
for n=1:43
b3(j,n,i)=(D(j,n,i)*(46-n)*(46-n-1)*(46-n-2))/(46*45*44*43);
end
end
end
end
end
  6 件のコメント
Namrata Chandel
Namrata Chandel 2022 年 5 月 6 日
b0(j,:,i)=D(j,:,i)/46; here 46 is length of the data of site 1.
dpb
dpb 2022 年 5 月 6 日
First, turn the calculation into a function that operates over the size of the inputs passed into it instead of hardcoding fixed limits for loops.
Then read in the data for each case into an array and call your function with it.
As noted above, the problem arises when you use hardcoded constants in the code instead of variables and also in not factoring out the code that does the same operations over each data set into a separate, callable function.

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeData Distribution Plots についてさらに検索

製品


リリース

R2013b

Community Treasure Hunt

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

Start Hunting!

Translated by