Use Matlab for the following question One definition of a bl
Use Matlab for the following question:
One definition of a blizzard is 4 or more consecutive hours of winds of 30mph or higher and visibility of 0.5 miles or less due to blowing snow. Data from one day of a storm has been stored in stormtrack.dat (see Blackboard). The three columns in order are hour of the day, wind speed in mph, and visibility in miles.
(a) Write a script that loads this data, checks the wind speed and visibility at each hour, and saves the hours that indicated blizzard-like conditions in a vector.
(b) Based on the definition, did this day have a blizzard? You may answer by inspection and put your result in a comment, or create code to evaluate the vector itself if you’re ambitious.
This is the data from stormtrack.dat
1.0000 30.0000 0.2000
2.0000 32.0000 0.3000
3.0000 35.0000 0.4000
4.0000 31.0000 0.5000
5.0000 28.0000 0.4000
6.0000 26.0000 0.3000
7.0000 20.0000 0.6000
8.0000 15.0000 0.8000
9.0000 13.0000 0.9000
10.0000 15.0000 0.7000
11.0000 13.0000 0.9000
12.0000 16.0000 0.6000
13.0000 18.0000 0.5000
14.0000 19.0000 0.4000
15.0000 24.0000 0.2000
16.0000 28.0000 0.3000
17.0000 32.0000 0.5000
18.0000 37.0000 0.5000
19.0000 40.0000 0.6000
20.0000 49.0000 0.5000
21.0000 53.0000 0.4000
22.0000 50.0000 0.3000
23.0000 46.0000 0.4000
24.0000 40.0000 0.3000
Solution
f1=fopen(\'c:\\stormtrack.dat\',\'r\');
hr = 0;
speed = 0;
vis = 0;
bl = [];
for i=1:24
t1 = fgets(f1);
c = textscan(t1,\'%f %f %f\');
hr = c{1};
speed = c{2};
vis = c{3};
if (vis <= 0.5 && speed >= 30)
bl =[bl hr];
end
end
disp(bl);
tmp = 1;
hr = bl(1);
start = hr;
for i=2:11
if(tmp == 4)
fprintf(\'\ Blizzard occured at %d hrs\ \', start);
end
if (bl(i) == (hr + 1))
tmp = tmp + 1;
else
tmp = 1;
start = bl(i);
end
hr = bl(i);
%disp(tmp);
end

