problem to get all values in for loop

2 ビュー (過去 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 Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by