필터 지우기
필터 지우기

problem to get all values in for loop

조회 수: 1 (최근 30일)
SOUVIK DATTA
SOUVIK DATTA 2019년 6월 28일
답변: Bob Thompson 2019년 6월 28일
Why am I getting the last value repeating for every value in each cell. Please help.
Thank you.
for i=1:3
for j=1: 5
for u=1: length(U)
if ~isempty(GradeU1{j,i})
FF=GradeU1{j,i}(:,u);
for k1=1:length(GradeU1{j,i}(:,u))-2
k2=k1+1;
for k3=k1+2: length(GradeU1{j,i}(:,u))
F1=([FF(1:k1); FF(k2)]);
F2=([FF(1:k1); FF(k3)]);
condCdf1 = condCop('clayton',F1.',AlfaClay(i),length(F1));
condCdf2 = condCop('clayton',F2.',AlfaClay(i),length(F2));
[~,pair21,~] = SOUVIKCOP('clayton',[condCdf1,condCdf2],AlfaClay(i));
for L=1:length(cop1{j,i}{:,u}{1})-k1
cop1{j,i}{u}{k1+1}(L)=pair21 ; % each cell arrays should have
% (4,3,2,1) no . of data..Now, i get all the values of pair21 right, but while
% storing them in the cell arrays of cop1, only the last value is being stored
% for 4 times or 3 times or 2 times.
end
end
end
end
end
end
end
  댓글 수: 2
Guillaume
Guillaume 2019년 6월 28일
편집: Guillaume 2019년 6월 28일
Why am I getting the last value repeating for every value in each cell.
How can we know? Your code is not commented, you've given no explanation of what it is attempting to be doing, we don't know anything about the input variables and we don't know what condCop and what SOUVIKCOP do, and you don't even tell us what the last value refers to nor what variable in each cell applies to.
SOUVIK DATTA
SOUVIK DATTA 2019년 6월 28일
please, check it again.

댓글을 달려면 로그인하십시오.

채택된 답변

Bob Thompson
Bob Thompson 2019년 6월 28일
I suspect you're getting the same result because you aren't changing the value of pair21 within the final loop.
for L=1:length(cop1{j,i}{:,u}{1})-k1
cop1{j,i}{u}{k1+1}(L)=pair21 ; % pair21 is assigned to each element of cop1{j,i}{u}{k1+1}, but pair 21 doesn't change in value

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by