Question: Please help me write this code using Matlab. I will make sure to upvote. Also, can you explain where to save the functions so that
Please help me write this code using Matlab. I will make sure to upvote. Also, can you explain where to save the functions so that they work as intended upon typing lab into the command window. Thanks so much.
Lab : Introduction to Matlab
Read sections of the Matlab tutorial document. To solve the problems below, you will have to
explore Matlab functionality using the Matlab "help" and you may have to browse through some of
the other tutorials listed in the Resources section. Create a script file called labm which will hold
all the commands necessary to produce the plots and computations below. Use comments to label
part part etc. Do not forget to move the file to your home directory before you leave the lab.
Vectors
a Generate a row vector of length containing the integers dots
b Generate a row vector containing values, each of whom is a random real number in the
interval
c Produce a new vector equal to the sum of the two vectors above.
d Plot the vector in
e Compute the following:
ielementbyelement division, for example divided by is
iieach element raised to the fourth power
iii. The dot product of and
f Plot the oddindex elements of the vector that isdots,
g Plot the elements of the vector between and that is dots,
h Plot the vectors in a and c on the same plot, using different colors.
i Plot all the plots in dg on the same figure.
Hint: help dot, colon, rand, plot, hold, subplot.
Functions
a Write a Matlab function named myfun that implements the following function:
The function takes a scalar as the input and outputs a scalar no vectors involved
b Plot the function myfun between and
c Write a Matlab function myfun that takes an input vector of size greater than two and
computes the sum of all the values in the vector that are not prime numbers. Example: for the
vector the sum is Apply your function to a vector of length of your choice
and also to the vector from question a
d Write a function myfun that accepts as input arguments a vector and two scalars and
and plots the function
exp
e Using the above function, plot for a vector with values from to step
and
Hint: help function, abs if fplot, find, isprime, sum.
Complex numbers, Loops
a Create a vector of length filled with complex numbers of your choice. Among the values
there should be some purely real and some purely imaginary numbers.
b Plot the vectors containing the real parts, imaginary parts, magnitudes, and phases of the
complex numbers. Plot them on four different plots on the same figure.
c Write a Matlab function myfun that takes an input vector and goes through all its compo
nents, one by one, printing out just the purely imaginary values. Apply your function to the
vector in
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
