how to split the data in for loop?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Alex Hanes
el 24 de Oct. de 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 comentarios
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!