How to run completely a loop inside one other?
1 次查看(过去 30 天)
显示 更早的评论
Hi! i have the data attached. ID_stop1 is an identifier of data and it is repeated 80 times for each value. Nn1 is a number from 1 to 20 and it is still repeated for each unique value of ID_stop1. Bn1 is a number from 1 to 20 and it is repeated for each unique value of Nn1. I need to access to data of L1 for each ID_stop1 and each Nn1. I created this code that works but at the end of the second loop it stops. How can i come back to the first loop?
I would like to have a cell array of 20 cells, and for each cell there should be 20 sub cells.
Any helps?
load ('sclerometrica_equotip_v1')
misure = [ID_stop L Nn Bn];
% misure(any(isnan(misure), 2), :) = [];
ID_stop1 = misure(:,1);
L1 = misure(:,2);
Nn1 = misure(:,3);
Bn1 = misure(:,4);
k = unique(ID_stop1);
for i = 1:numel(k)
index = (ID_stop1 == k(i));
N= Nn1(index); %battute nodi
j = unique(N);
for m = 1:numel(j)
index2 = (N == j(m));
L_nodo = L1(index2);
result{m} = L_nodo;
end
end
0 个评论
采纳的回答
Bob Thompson
2019-3-6
I suspect that the issue is not that the code actually stops, but that the results are only recorded for one internal loop. If you want cells inside of cells then you need to index for each loop.
results{i}{m} = L_nodo;
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!