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
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 CenterFile Exchange에서 Data Distribution Plots에 대해 자세히 알아보기

제품


릴리스

R2013b

Community Treasure Hunt

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

Start Hunting!

Translated by