A blizzard is a massive snowstorm. Definitions vary, but for our purposes, we will assume that a blizzard is characterized by both winds of 30 mph or higher and blowing snow that leads to visibility of 0.5 miles or less, sustained for at least 4 hours. Data from a storm one day has been stored in a file stormtrack.dat. There are 24 lines in the file, one for each hour of the day. Each line in the file has the wind speed and visibility at a location. Create a sample data file. Read this data from the file and determine whether blizzard conditions were met during this day or not.

Respuesta :

Answer:

The weather conditions do not suggest a blizzard. It is explained below.

Explanation:

wind_speed=randi([12 56],24,1);

visibility=randi([1 10],24,1)/10;

storm_data=[wind_speed,visibility];

save stormtrack.dat storm_data -ascii

clear

load stormtrack.dat

fprintf('Below is the storm data from the file stormtrack.dat \n');

disp(stormtrack)

wind_speed=stormtrack(:,1);

visibility=stormtrack(:,2);

L=length(wind_speed);

count=0;

i=0;

while count<4 && i<L

i=i+1;

if wind_speed(i)>=30 && visibility(i)<=0.5

count=count+1;

else

count=0;

end

end

if count==4

fprintf('The weather conditions suggest a blizzard.\n')

else

fprintf('The weather conditions do not suggest a blizzard.\n')

end

Results:

Below is the storm data from the file stormtrack.dat  

49.0000 0.1000

56.0000 0.4000

44.0000 0.6000

27.0000 0.7000

38.0000 0.5000

16.0000 0.9000

52.0000 0.8000

1 51.0000 1.0000

48.0000 0.6000

23.0000 0.4000

38.0000 0.2000

13.0000 0.7000

31.0000 0.8000

26.0000 0.5000

19.0000 0.1000

20.0000 0.3000

31.0000 0.2000

16.0000 0.3000

38.0000 0.5000

33.0000 0.6000

43.0000 0.5000

43.0000 0.9000

40.0000 0.6000

13.0000 1.0000

The weather conditions do not suggest a blizzard.

ACCESS MORE
ACCESS MORE
ACCESS MORE
ACCESS MORE