problem to get all values in for loop

1 次查看(过去 30 天)
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.

请先登录,再进行评论。

采纳的回答

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