CSC 113 George Mason University Script Files and Function Files Lab Report

I have attached the exercises. please do them and then send me the source code (.m) files here as usual.

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

Spring 2021
CSC 113 Intro. To Programming with MATLAB
05/04/2021
Name:________________________
Complete all programs in MATLAB script files and function files as appropriate.
You may separate different problems into different files as needed, but please name files
appropriately.
1. Write a MATLAB program to create a new figure split into 3 subplots, all in a row,
plotting the three graphs listed below: (25 points)
a. Plot a polar plot of the sine, cosine, and tangent function for 360 angles over the
range theta = 0 to 2π. Display an appropriate legend for the plots.
b. Plot a bar plot showing the point value of each question on this exam. Label the xaxis “Question” and the y-axis “Point value.”
c. Plot f(x)=2^X over a range of x= 1 to 25 using fplot. Label the axis appropriately.
2. Write a MATLAB program that acts as a simple calculator. The program should ask the
user for a number, then an operator (either ‘+’, ‘-’, ‘*’, or ‘ /’), and then another number.
The program should calculate the result and display it.
INPUT VALIDATION: Ask for new input if the user enters any other character besides
the four given operators or tries to divide by zero. (30 points)
3. Let the mathematical function u() be defined as:
u(1)=3
u(2)=2
u(n)=n*u(n-1)+(n+1)*u(n-2)+n
For example, u(3) = 3*u(2)+4*u(1)+3 = 21
Write a function that accepts as input an integer N and then returns a vector of the values
of u(1 through N). Demonstrate the function with a script file that asks the user to enter a
value N and calls the function with it. Plot the resulting values, labeling the graph
appropriately.
Input Validation: Ask for new input if the user enters a number less than 1 for N.
(30 points)
4. Write a MATLAB script file to solve the following system of linear equations via matrix
algebra. Display the value of each variable to the screen (eg. “x = 1, y = 2, and z = 3”).
(15 points)
4𝑥+3y-2𝑧=0
𝑥+7𝑦-3z=5
𝑥-2𝑦+z=6
Extra Credit: The Grand Admiral has grown weary of the constant Rebel attacks and has
ordered you to develop an algorithm to locate their hidden base. He has theorized that, given the
standard (x,y) galactic coordinates of the planets attacked, the known effective range of Rebel
ships (4 standard galactic units), and a list of candidate planets where their base may be located,
one could determine which locations are most likely for their base. (+20 points)
You are ordered to create a program that:





Asks the user to provide the 2D galactic coordinates of all attacked planets (Per standard
galactic format, they should range from [-10,-10] to [10,10]). The user must be able to
provide as many planets as they need.
Asks the user to provide the galactic coordinates of candidate base planets. The user must
be able to provide as many planets as they need.
Plots a galactic map of the entered planets (distinguishing attacked and candidate base
plates).
Plots circles on the map indicating the maximum distance from the attacked planets the
Rebel ships could have originated from.
Determine and indicate on the plot which candidate base planets are within range of all
attacked planets.
o If no planets are within that range, display a message indicating this.
.m
e3.m

Still stressed from student homework?
Get quality assistance from academic writers!

Order your essay today and save 25% with the discount code LAVENDER