Write a MATLAB code to obtain the following. Keep yourcode commented whenever required. Copy your source code and commandwidow outcomes and screen shots of any plots in yoursolution.
Write a user defined function ‘My_FunctionGen’. Itaccepts, the time vector ‘t’ with 8000 uniformly spacedvalues within the range of 0 to 8, Frequecyscalars ‘f1<100H’ and ‘f2<80Hz’ andAmplitude scalars ‘A1’, ‘A2’ and ‘A3’ asinput arguments. It delivers x1, x2 andx3 and x4 as outputs and also generates plots, asshown in the following table. Where, x1, x2, x3and x4 are defined as.
- x1= (A1+A2).cos(2Ï€f1t)
- x2= A2.cos(2Ï€f2t)
- x3= A3 times of a random vector of a similar length as that ofvector ‘t’
- x4= Element by element division between x1 and x2
- Open Figure#8, split this figure as shown below and draw:
Plot vector ‘x1’ against vector‘t’ in blue color. (Row 1, Column 1) |
Plot vector ‘x2’ against vector‘t’ in red color. (Row 1, Column 2) |
Plot vector ‘x3’ against vector‘t’ in cyan color. (Row 2, Column 1) |
Plot vector ‘x4’ against vector‘t’ in green color. (Row 2, Column 2) |
[Superposition of data plots] Plot vector ‘x4’ against vector‘t’ in magenta color. Plot vector ‘x3’ against vector‘t’ in black color. Plot vector ‘x2’ against vector‘t’ in blue color. (Row 3, Column 2) |
- Use axis function to properly displayeach plot. Also add, x-axis label,y-axis label,Title andLegend to these plots.
- Write an appropriate MATLAB code to call and test thisfunction.