If all points are equal then
1 view (last 30 days)
Show older comments
Hi everyone,
I have a cell with different arrays. The arrays contains different matrices (for example 72x2 double, 5x2 double, or 3x2double).
Now I want to have to if clauses. The first on is, that if the matrice is smaller then 5x2 a logical 0 results.
The same should happen when all entries of the first column of the matrice are equal to each other or when all entries of the second column are equal to each other.
How can I reach this?
for ii=1:length(xLoc)
for kk=1:length(area)
if length(points{kk}(:,1))<5 %5
in(kk)=false;
elseif points{kk}(:,2)==%equal to each other
in(kk)=false;
elseif points{kk}(:,1)==%equal to each other
else
edges = convhull(points{kk}(:,1),points{kk}(:,2));
in(kk) = inpolygon(xLoc(ii),yLoc(ii),points{kk}(edges,1),points{kk}(edges,2)); % true if VortexLoc is inside area
end
end
end
Thanks for your help!!
0 Comments
Answers (1)
Yazan
on 1 Jul 2021
% generate 3 matrices for a demo
A1 = randn(72,2);
A2 = randn(5,2);
A3 = randn(3, 2);
% generate a structure
s = {A1, A2, A3};
% 3 logical statement
f1 = cellfun(@(x) size(x,1)<5, s);
f2 = cellfun(@(x) all(x(:,1)==x(1,1)), s);
f3 = cellfun(@(x) all(x(:,2)==x(1,2)), s);
% or merge f1 and f2 and f3 in one logical statment
% f4 = f1 or f2 or f3
f4 = cellfun(@(x) size(x,1)<5 | all(x(:,1)==x(1,1)) | all(x(:,2)==x(1,2)), s);
0 Comments
See Also
Categories
Find more on Image Processing Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!