Wind and temperature divided into speed and temp
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
Jan
2013-9-24
Please post a meaningful example of the input in Matlab syntax and the wanted output. The description in text form is not clear enough.
回答(2 个)
Image Analyst
2013-9-24
编辑:Image Analyst
2013-9-24
logicalIndexes = windSpeed == 0 & (temp > -15 & temp < -10);
count = sum(logicalIndexes);
% Display the temps that have 0 wind speed
temp(logicalIndexes)
Youssef Khmou
2013-9-24
编辑:Youssef Khmou
2013-9-24
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
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!