Question
matlab
1. [suDmit as Iwo JPEGS in Canvas with your netiD in the title of each plot] An electricity startup is looking into the viabi
sll Verizon LTE 6:55 PM 65% inst-fs-iad-prod. inscloudgate.net - A plot of the mean sunlight each calendar month and the mini
100 Your plots should have - A title that is informative and includes your netID. Plots without your netID will be marked as
1. [suDmit as Iwo JPEGS in Canvas with your netiD in the title of each plot] An electricity startup is looking into the viability of putting solar panels on the rooftops of buildings in Newark, NJ. They want you to help them come up with visualizations for data they have from the National Renewable Energy Laboratory and the National Oceanic and Atmospheric Administration about: - The average amount of sunshine received each month in the form of Global Horizonal Irradiation (GHI) -The amount of snowfall Newark received each month in millimeters From the years 1999 through 2017 (19 years total). The company needs to know about the amount of sunshine Newark receives each month to know what the average output of solar panels might be per month, and they need to know about snowfall to understand the maintenance costs that might be associated with keeping panels operational in the summertime. Please download the csv dataset provided for you as sunData.csv. This data has four columns: - The first column is the year - The second column is the month (1-12) - The third column is the average GHI for that month - The fourth column is the total snowfall for that month You should write a script or a function that creates the following two plots - A plot of the mean snowfall each calendar month and the maximum snowfall each calendar month for the years 1999 through 2017. It should look like this: Comparison of mean and maximum snawfall per month in Newark, NJ between the years 1999 and 2017 1000 mean 800i 700 Full Plot Hidden E 600 s00 400 a00 200 100 1 4 10 11 12 Morth
sll Verizon LTE 6:55 PM 65% inst-fs-iad-prod. inscloudgate.net - A plot of the mean sunlight each calendar month and the minimum sunlight for each calendar month for the years 1999 through 2017. It should look like this Comparison of mean and minimum sunlighe per month in Newark, NJ between the years 1999 and 2017 Full Plot Hidden Month Your plots should have - A title that is informative and includes your netlD. Plots without your netID will be marked as 0! -Labels for the x and y axis - A legend - x limits of and 12 (your x-axis should only display between these values) Hints - You should be creating at least 4 arrays with 12 elements each, representing the 4 different lines you have to plot. - You can use the Month column of sunData to get the index you should be using for each of the 4 arrays: o If you have data for month 3, you should be working with the 3" index of your arrays! -Think back to how we calculated the mean of an array without using the mean command. You will have to do something similar here. - The minimum/maximum values you must find here are by month. This means that you have to compare all of the values from month 4 against each other to find the minimum/maximum. You should know that there are no values above 1000, and none below 0, so these are acceptable starting points for minimum and maximum for each month (respectively) Once you create these plots, you the following: - In MATLAB, go to the "File" menu, then "Save as..." option in the Figure containing the plot. Then under the can save them by doing
100 Your plots should have - A title that is informative and includes your netID. Plots without your netID will be marked as 0! - Labels for the x and y axis - A legend x limits of 1 and 12 (your x-axis should only display between these values) Hints: - You should be creating at least 4 arrays with 12 elements each, representing the 4 different lines you have to plot. - You can use the Month column of sunData to get the ndex you should be using for each of the 4 arrays: o If you have data for month 3, you should be working with the 3" index of your arrays! - Think back to how we calculated the mean of an array without using the mean command. You will have to do something similar here - The minimum/maximum values you must find here are by month. This means that you have to compare all of the values from month 4 against each other to find the - minimum/maximum. You should know that there are no values above 1000, and none below 0, so these are acceptable starting points for minimum and maximum for each month (respectively) Once you create these plots, you can save them by doing the following: - In MATLAB, go to the "File" menu, then "Save as.." option in the Figure containing the plot. Then under the "Save Type As" menu, select JPEG. Name your file and press Save. - In MATLAB Online the instructions are the same, but the "File" menu is at the top of the screen in the Figure tab. You must then download your image using the Download button in the Home tab INote, MATLAB Online plots might look slightly different. This is OK Submit both JPEGS on Canvas
0 0
Add a comment Improve this question Transcribed image text
Answer #1

No csv file given by you. Using my own file with random data for 2 years. Remember to change the num_years variable when you use the correct file. Also, don't forget to add you "netID" to the plot title!

%% MATLAB code begins %%
% Read the file, create variables
data = readmatrix("convertcsv.csv");
avg_snowfall = zeros(1, 12);
max_snowfall = zeros(1, 12);
avg_sunlight = zeros(1, 12);
min_sunlight = ones(1, 12) * inf;
num_years = 2019 - 2018 + 1;
% Process the data
for i = 1:length(data)
    month = data(i, 2);
    snowfall = data(i, 4);
    sunlight = data(i, 3);
    avg_snowfall(month) = avg_snowfall(month) + snowfall;
    max_snowfall(month) = max(max_snowfall(month), snowfall);
    avg_sunlight(month) = avg_sunlight(month) + sunlight;
    min_sunlight(month) = min(min_sunlight(month), sunlight);
end
% Divide, because these arrays only have the sum till now
avg_snowfall = avg_snowfall / num_years;
avg_sunlight = avg_sunlight / num_years;
% Generate plots
figure(1);
hold on;
plot(avg_snowfall);
plot(max_snowfall);
xlim([1, 12]);
title({'Comparision of mean and maximum snowfall per month in Newark, NJ', 'between the years 1997 and 2017'});
xlabel('Month');
ylabel('Snowfall in mm');
legend('Average Snowfall', 'Maximum Snowfall');
figure(2);
hold on;
plot(avg_sunlight);
plot(min_sunlight);
xlim([1, 12]);
title({'Comparision of mean and minimum sunlight per month in Newark, NJ', 'between the years 1997 and 2017'});
xlabel('Month');
ylabel('Global Horizontal Irrandiance (A Measure of Total Sunlight)');
legend('Average Sunlight', 'Minimum Sunlight');

%% MATLAB code ends %%

Add a comment
Know the answer?
Add Answer to:
matlab 1. [suDmit as Iwo JPEGS in Canvas with your netiD in the title of each...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • cope the code please thanks Write a MATLAB code to obtain the following. Keep your code...

    cope the code please thanks Write a MATLAB code to obtain the following. Keep your code commented whenever required. Copy your source code and command widow outcomes and screen shots of any plots in your solution. Generate a matrix "A" as follow. A= 16 6 8 2 10 18 12 14 4 I. II. Divide the matrix A by 2 and store the result in a matrix B. Combine matrices A & B to obtain the following matrix C. Also...

  • MATLAB QUESTION !!! PLEASE USE MATLAB FOR BOTH QUESTIONS!!! THANKS 3) Below is a matrix of...

    MATLAB QUESTION !!! PLEASE USE MATLAB FOR BOTH QUESTIONS!!! THANKS 3) Below is a matrix of random numbers. Find the mean, median, and mode of the matrix. B=[0 1 2 3 4 50689 23092 6 8 407] Sort Matrix Z so that the largest numbers of each row are in the first column and smallest numbers descend towards the last column. Must use sort function. 4) Create a matrix X so that the first row has values from 0 to...

  • 1) Create a matlab function that calculates: for Name your function TwoVarFunc : The inputs should...

    1) Create a matlab function that calculates: for Name your function TwoVarFunc : The inputs should be in the same order: xmin xmax ymin ymax N: n is the number of elements in the vector x and y The ouputs should be in the same order: f_xy: is the calculated array f(x,y) f_xyMAX: should be the the maximum value of the function f(x,y). Hint: to create vectors x and y look up the matlab built-in function linspace() Hint 2: To...

  • Problem 1. (20) The purpose of this exercise is for you to get familiar with MATLAB...

    Problem 1. (20) The purpose of this exercise is for you to get familiar with MATLAB and some of its capabilities. We have seen in class that, for a positive integer n and data {(rj, yj)|j= 0,...n}, the matrix system produces the coefficients of the polynomial Pn(x) coc1x++ cn&" that interpolates the data, where [Vn]ij = x;_{ for 1 < i,j <n+1. Let r j/n, giving a uniformly spaced set of n 1 points in [0, 1]. Write a MATLAB...

  •    MATLAB SCRIPT PLEASE Matlab MATH 210 in 2020 Homework Assignment 8- Due 3/25, 11:59PM Each...

       MATLAB SCRIPT PLEASE Matlab MATH 210 in 2020 Homework Assignment 8- Due 3/25, 11:59PM Each plot should have its own figure associated with it. In all questions, give the figure a title, and label the acis. Save your matlab script as drill 10.m Do not use the fplot command. 1. Plot the function f(x) = (x + 5)2 for -5 <<<10. Include a plot title, and label both aris. 2. Use the subplot command to make two plots of...

  • Problem 1 MATLAB A Taylor series is a series expansion of a function f()about a given point a. For one-dimensional real...

    Problem 1 MATLAB A Taylor series is a series expansion of a function f()about a given point a. For one-dimensional real-valued functions, the general formula for a Taylor series is given as ia) (a) (z- a) (z- a)2 + £(a (r- a) + + -a + f(x)(a) (1) A special case of the Taylor series (known as the Maclaurin series) exists when a- 0. The Maclaurin series expansions for four commonly used functions in science and engineering are: sin(x) (-1)"...

  • Matlab Matlab Matlab Matlab, Please solve this problem Problem 4 : Runge's phenomenon For this proble,...

    Matlab Matlab Matlab Matlab, Please solve this problem Problem 4 : Runge's phenomenon For this proble, you wil interpolate the function h(x) = tanh(10x) in I [a, b, through n datapoints (xi, hx with equidistant nodes for several values of n, and observe the behavior of the interpolating polynomial as n increases. You should use the pair of functions polyfit and polyval In your prob40: (a) Interpolate the function tanh(10x) in [-1,1] using a uniform grid of n nodes, where...

  • I need help solving these questions,please don’t know how to solve it by using matlab.!

    i need help solving these questions,please don’t know how to solve it by using matlab.! Solve the following questions Ol: You are required to develop a script to calculate the volume of a pyramid, which is 1/3 *base *height, where the base is length *width. Prompt the user to enter values for the length, width, and height, and then calculate the volume of the pyramid. When the user enters each value, he or she will then also be prompted to...

  • what is a good matlab code to out put this matrix from question 1 to 3...

    what is a good matlab code to out put this matrix from question 1 to 3 HITA 1)-The general form cf the quadratic equation is a +bx+c 0 Wrte a MATLAB function named quadratic that finds the two roots of this equation and x when given the coeficients a, b and c 2)-Create a random matrix A in MATLAB with 6 rows and 3 oolumns using the rand) function 3)-Now modify quadratic by so that il can take each row...

  • please solve then upload matlab code Thanks 1. The function f(z, y) (a-x)2 + b(y-12)2 is...

    please solve then upload matlab code Thanks 1. The function f(z, y) (a-x)2 + b(y-12)2 is called Rosenbrock's banana function. It is often used as a benchmarking test for optimization algorithms becatse it is easy to find the minimum by hand but often very difficult to find numerically. Throughout the problem, we will use the values a = 2 and b 10. You can plot this function using the following code: x3:0.1:3; y = -10:0.2:10; Cx,Ymeshgrid(x,y); Z(2-X).2 10* (Y-X. 2)....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT