Finding a series of numbers in a vector which correspond with a series of numbers in a different vector.
Show older comments
I Have two vectors for example,
Yaw = [9 9 8 9 10 10 10 10 14 15 15 15 15];%Degrees,
Speed = [212 212 213 180 200 190 200 200 200 210 210 210 150];%KNOTS
I need to count the number of times Yaw is at 9 and Speed above 210. In other words
for i = 1:length(Yaw)
if Yaw(i) == 9 && Speed(i) >= 210;
count9 = count9 + 1;
elseif Yaw(i) == 10 && Speed(i) >= 200;
count10 = count10 + 1;
elseif Yaw(i) == 15 && Speed(i) >= 150;
count15 = count15 + 1;
end
end
Is there a more efficient way. The vectors I am working with are very large. I also need to know the indices. i.e. the exact speed at the 9 10 or 15 degrees yaw in order to perform further calculations.
I'd appreciate any advice. Thanks
Accepted Answer
More Answers (0)
Categories
Find more on MATLAB 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!