Wind and temperature divided into speed and temp

1 vue (au cours des 30 derniers jours)
Jenny
Jenny le 24 Sep 2013
Commenté : Jenny le 26 Sep 2013
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
  2 commentaires
Jan
Jan le 24 Sep 2013
Please post a meaningful example of the input in Matlab syntax and the wanted output. The description in text form is not clear enough.
Jenny
Jenny le 26 Sep 2013
My apologies. A more detailed request is posted below as a comment under Image Analyst's answer. There are also the two relevant attached files.

Connectez-vous pour commenter.

Réponses (2)

Image Analyst
Image Analyst le 24 Sep 2013
Modifié(e) : Image Analyst le 24 Sep 2013
logicalIndexes = windSpeed == 0 & (temp > -15 & temp < -10);
count = sum(logicalIndexes);
% Display the temps that have 0 wind speed
temp(logicalIndexes)
  1 commentaire
Jenny
Jenny le 26 Sep 2013
Thank you for this answer. This is how to process the data 'manually' i.e.
Indexes_event1 = NewWindSpd <=1 & (NewTempData >= -15 & NewTempData < -10);
count_event1 = sum(Indexes_event1);
Indexes_event2 = NewWindSpd <=1 & (NewTempData >= -10 & NewTempData < -5);
count_event2 = sum(Indexes_event2);
Indexes_event3 = NewWindSpd <=1 & (NewTempData >= -5 & NewTempData < 0);
count_event3 = sum(Indexes_event3);
Which is repeated 9 times for the temperature groups and then 14 times again for the different wind groups.
I am trying to put this into a loop so that I have a more 'elegant' code, rather than almost 300 lines of code.
The TempData groups are: -15 to -10; -10 to -5; -5 to 0; 0 to 5; 5 to 10; 10 to 15; 15 to 20; 20 to 25; 25 to 30.
The WindSpd groups are: <1; 1 to 3; 3 to 5; 5 to 7; 7 to 9; 9 to 11; 11 to 13; 13 to 15; 15 to 17; 17 to 19; 19 to 21; 21 to 23; 23 to 25; >25.
Thanks for your help, Jenny

Connectez-vous pour commenter.


Youssef  Khmou
Youssef Khmou le 24 Sep 2013
Modifié(e) : Youssef Khmou le 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
  1 commentaire
Jenny
Jenny le 26 Sep 2013
Thank you for this. I have posted the question in more detail under Image Analyst's answer. I am working on fitting your to my data.

Connectez-vous pour commenter.

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by