Data Extraction using Logical Operators
Show older comments
Trying to write code that will extract data from a set between two values and store the number of times data in the set matches the criteria into an array, this is the code that I have:
v = (1:1:20) ; %wind speed
n = 0;
hours1 = zeros();
hours2 = zeros();
for n = 1:length(v)
temp = 0;
temp2 = 0;
if(wind_adj1 < n & wind_adj1 > n - 1)
temp = 1 ;
if(wind_adj2 < n & wind_adj2 > n - 1)
temp2 = 1;
end
end
hours1(n+1,1) = temp;
hours2(n+1,1) = temp2;
end
For thie first iteration of the loop, I'd like to know how many cells from the dataset are between 0 m/s and 1 m/s (the data is hourly wind speed.) I'd like for the loop to continue to 20 m/s and the intended use of the data is to generate a Rayleigh probability density function (pdf.) I'm confident that the issue is in how I'm structuring the logical check, but I've worked on it for a few hours and haven't cracked it. Any help or advice the could be given would be appreciated.
Accepted Answer
More Answers (0)
Categories
Find more on Mathematics 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!