Wind and temperature divided into speed and temp
Show older comments
Is there a function to create a matrix with a count (i.e. number of occurrences) where wind speed goes from 0 m/s to 28 m/s in 1m/s intervals along the y axis (downwards i.e. 0 m/s at the top) and temperature goes from -15 deg C to 30 deg C in 5 deg C intervals, along the x-axis?
I have temperature time series data and wind speed time series data. I would like a matrix of counts that tells me how many times a combination of data occurred. For example, count how many time wind speed was 0 m/s and temp was between -15 and -10 deg C.
I can do this manually. I was wondering if there was a more elegant way of 'counting' the combinations and displaying the matrix.
Thank you, Jenny
Answers (2)
Image Analyst
on 24 Sep 2013
Edited: Image Analyst
on 24 Sep 2013
logicalIndexes = windSpeed == 0 & (temp > -15 & temp < -10);
count = sum(logicalIndexes);
% Display the temps that have 0 wind speed
temp(logicalIndexes)
Youssef Khmou
on 24 Sep 2013
Edited: Youssef Khmou
on 24 Sep 2013
Jenny, try this version ,
wind=round(20*rand(20,1)); % arbitrary wind time series .
temp=round(10*randn(30,1)); %arbitrary temperature time series .
W0=5; % your critical value of wind speed
temp1=5; % bound1
temp2=15; % bound 2 , critical values of temperature
e=1e-2; % Tolerance of the logical == operation
% Replace wind and temp with your input
M=length(wind);
N=length(temp);
I=zeros(M,N); % your counting matrix
for x=1:M
for y=1:N
if (abs(wind(x)-W0)<=e) && (temp(y)>=temp1 && temp(y)<=temp2)
I(x,y)=1;
end
end
end
figure, surface(I);
title(' detection of specific values ');
sum(I(:)) % number of occurence
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!