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 vue (au cours des 30 derniers jours)
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 commentaires
Namrata Chandel
Namrata Chandel le 6 Mai 2022
b0(j,:,i)=D(j,:,i)/46; here 46 is length of the data of site 1.
dpb
dpb le 6 Mai 2022
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.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Data Distribution Plots dans Help Center et File Exchange

Produits


Version

R2013b

Community Treasure Hunt

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

Start Hunting!

Translated by