WSFO =[6.7 7.5 8.5 9.5 10.4 10.9 11.2 10.5 9.1 7.6 6.3 6.5];WOrl =[9.0 9.6 9.9 9.4 8.8 8.0 7.3 7.2 7.7 8.6 8.6 8.5];Month={'Jan' 'Feb' 'Mar' 'Apr' 'May' 'Jun' 'Jul' 'Aug' 'Sep' 'Oct' 'Dec'};A = mean(WSFO);B = mean(WOrl);fprintf(['\nThe average annual wind speed in San Francisco was (mph)'... '\n %f\n'], A);fprintf(['\nThe average annual wind speed in Orlando was'... '(mph)\n %f\n'], B);C = round(sum(WSFO<A));D = round(sum(WOrl<B));fprintf(['\nWind speed is below the annual average in San Francisco' ... ' for \n %f months\n'], C);fprintf(['\nWind speed is below the annual average in Orlando for'... '\n %f months\n'], D);E = sum(WSFO > WOrl);fprintf(['\nWind speed in San Francisco higher than in Orlando '... 'during the %d months of\n'], E);if WSFO > WOrl fprintf('%s %s\n',E, Month{1:2:3:4:5:6});endF = abs(WSFO - WOrl) <= .2;if abs(WSFO - WOrl) <= .2fprintf(['\nWind speed in San Francisco is within ±0.2mph of that in '... 'Orlando during the %d months of\n'], Apr);end
MATLAB: I am trying to use if statements to compare two vectors to get a value from a third. I need to display which months of one vector are higher than another then give the months that they are within .2 of each other.
fprintfif
Best Answer