How to remove open contours
Afficher commentaires plus anciens
I have a volume of data. At each x location, I'd like to process some contours in the y-z plane. As part of that, I'd like to only consider the closed contours. I'm trying to do this by filtering out any contours that touch the edge of the plane (they could technically be tangent, but I'm willing to risk that). Here's my code with more explanations in comments.
for i = 1:length(xinds) % looping through x locations
yzconlev{i} = contourc(zdim,ydim,squeeze(uavgdef(xinds(i),:,:))',levs); % creating contours
[yzczdim{i},yzcydim{i},yzcuavgdef{i}] = C2xyz(yzconlev{i}); % Using C2xyz to get interpolated
% grid data of each contour
for j = 1:length(yzcuavgdef{i}) % looping through contours at each x
coniny{i}{j} = find(yzcydim{i}{j}~=ydim(1) & yzcydim{i}{j}~=ydim(end)); % find contours
% that touch the edge as defined by ydim
coninz{i}{j} = find(yzczdim{i}{j}~=zdim(1) & yzczdim{i}{j}~=zdim(end)); % same, but for
% other dimension
if size(coniny{i}{j}) == size(yzcydim{i}{j})
iny{i}{j} = yzcydim{i}{j};
end
if size(coninz{i}{j}) == size(yzczdim{i}{j})
inz{i}{j} = yzczdim{i}{j};
end
if isempty(iny{i}{j}) == 0 && isempty(inz{i}{j}) == 0
iny2{i}{j} = iny{i}{j}; % can't index with j if I want to skip some...
inz2{i}{j} = inz{i}{j};
end
% would then continue processing only with closed contours
end
end
This is close. I get only closed contours in iny and inz, but it leaves empty cells where the open contours were, and now I need to find the intersection of the two. I have the start of a solution, but I'm struggling to figure out how to index it so it works. As is, I still get empty cells as a result of skipping some js based on the condition.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Contour Plots dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!