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 Ansicht (letzte 30 Tage)
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 Kommentare
dpb
dpb am 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.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Data Distribution Plots finden Sie in Help Center und File Exchange

Produkte


Version

R2013b

Community Treasure Hunt

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

Start Hunting!

Translated by