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 %%
matlab 1. [suDmit as Iwo JPEGS in Canvas with your netiD in the title of each...
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 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 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 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 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-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, 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.!
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
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 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)....