how to split the data in for loop?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
inter_point = [];
idx = [];
tic
parfor k = 1:length(x1)
for i = 1:length(Arr_1516)
for j = 1:length(Arr_1516(i).Longitude)-1
p1 = [x1(k),y1(k)];
p2= [x2(k),y2(k)];
L1 = [Arr_1516(i).Longitude(j), Arr_1516(i).Longitude(j+1);
Arr_1516(i).Latitude(j), Arr_1516(i).Latitude(j+1)]; % Line 1 : Mean Trajectory
L2=[p1(1,1),p2(1,1);p1(1,2),p2(1,2)]; % Line 2 : Line
inter = InterX(L2,L1);
if isempty(inter)
idx=[idx;i];
continue
end % if
inter = [inter(1,1),inter(2,1)];
inter_point = [inter_point;inter];
end % j
end % k
end % i
toc
I want to split the data when k is moving to next number.
I tried with this code to inster NaN NaN. but it didnt work at all
inter_point = [inter_point;inter;NaN NaN];
0 Kommentare
Antworten (1)
Alex Hanes
am 24 Okt. 2022
It looks like your issue is because your parfor loop violates the following static condition:
Required (static): If you use a nested for-loop to index into a sliced array, you cannot use that array elsewhere in the parfor-loop.
You can see the requirements on this page: https://www.mathworks.com/help/parallel-computing/nested-parfor-loops-and-for-loops.html
0 Kommentare
Siehe auch
Kategorien
Mehr zu Parallel for-Loops (parfor) 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!