problem to get all values in for loop

2 Ansichten (letzte 30 Tage)
SOUVIK DATTA
SOUVIK DATTA am 28 Jun. 2019
Beantwortet: Bob Thompson am 28 Jun. 2019
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 Kommentare
Guillaume
Guillaume am 28 Jun. 2019
Bearbeitet: Guillaume am 28 Jun. 2019
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 am 28 Jun. 2019
please, check it again.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Bob Thompson
Bob Thompson am 28 Jun. 2019
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

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by