Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The m-file create_cell_example.m creates a cell array with the average monthly precipitation values for three cities. The array also contains the names of the cities,

The m-file create_cell_example.m creates a cell array with the average monthly precipitation values for three cities. The array also contains the names of the cities, the names of the precipitation types and strings containing abbreviations of the months of the year. Start with the template file cell_exercise_template.m to create an m-file (named cell_exercise_LastName.m) that produces a bar chart of the average monthly rainfall and snowfall for Minneapolis. You must use cell-array indexing to access the strings for use in the title, legend and x-axis tick labels.

% % create_cell_example.m %

clear all close all

cities = {'New Orleans','Minneapolis','San Diego'}; precip_type = {'rain','snow'}; months = {'Jan','Feb','Mar','Apr','May','Jun',... 'Jul','Aug','Sep','Oct','Nov','Dec'};

% City 1: New Orleans % average monthly rainfall (inches) precip_amt(1,1,:) = [5.05 6.01 4.90 4.50 4.56 5.84 ... 6.12 6.17 5.51 3.05 4.42 5.75]; % average monthly snowfall (inches) precip_amt(1,2,:) = zeros(1,12);

% City 2: Minneapolis % average monthly rainfall (inches) precip_amt(2,1,:) = [0.95 0.88 1.94 2.42 3.39 4.05 ... 3.53 3.62 2.72 2.19 1.55 1.08]; % average monthly snowfall (inches) precip_amt(2,2,:) = [12.1 7.8 10.2 2.5 0.01 0 ... 0 0 0.01 0.6 9.3 11.5];

% City 3: San Diego % average monthly rainfall (inches) precip_amt(3,1,:) = [1.80 1.53 1.77 0.79 0.19 0.07 ... 0.02 0.10 0.24 0.37 1.45 1.57]; % average monthly snowfall (inches) precip_amt(3,2,:) = zeros(1,12);

% Place city name strings in cell{1} % Place precipitation type name strings in cell{2} % Place month name strings in cell{3} % Place precipitation amounts in cell{4} avg_precip = {cities,precip_type,months,precip_amt}; clear cities precip_type months precip_amt

% % cell_exercise.m % % clear all close all

% Call the m-file that creates the cell array create_cell_example

% assign the array of rain/snow values from City 2 to a 2x12 matrix ap2(1:2,:) = ????????

% create a bar chart of both the rain and snow values for City 2 bar(1:12,????) % set the XTickLabel for gca to use the month abbreviations set(gca,'XTickLabel',??????) % specify the ylabel ????? % Specify the title using the name string for City 2 title(horzcat('Average Monthly Precipitation for ',????????)) % Set the legend utilizing the precipitation name strings ?????

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Management Systems

Authors: Mark L. Gillenson

2nd Edition

0470624701, 978-0470624708

More Books

Students also viewed these Databases questions

Question

Tell the merits and demerits of Mendeleev's periodic table.

Answered: 1 week ago