Each of these problems is to be written using m-files for the code instead of th
ID: 3802844 • Letter: E
Question
Each of these problems is to be written using m-files for the code instead of the Matlab command window. Remember to include: Problem statements, the m file code (copied and pasted), any inputs from the MATLAB command window, and plots and labels). All code should be run and all the code output included as part of the problem. All work will be put into one file (WORD or PDF and then sent to me). All specified inputs are to be entered into the m file using the Matlab command window. Write an m-file that will plot three sine functions for three different sampling rates (this is not the frequency), and will use a loop to generate the functions and plots. Input to the m file: Three step sizes (sampling rates) of: 0.001,0.01,0.1 Domain: t goes from -5 to 5 using the increments that are input to the file Loop: Find the function: y=cos(t) Plot t and y in subplots (3 rows and 1 column), one plot per subplot Labels: time axis: time in seconds Vertical axis: cos(t) Title: cos(t) with sampling rate = _ (instead of the _ put the step size used for that plot)Explanation / Answer
%Time frames which will increment by step sizes
t1=[-5:0.001:5];
t2=[-5:0.01:5];
t3=[-5:0.1:5];
A=1;
f=1000;
y1=A*cos(f*t1);
y2=A*cos(f*t2);
y3=A*cos(f*t3);
%Plotting sinusoidal waves
plot(t1,y1);
title('cos(t) with sampling rate 0.001');
xlabel('Time in seconds');
ylabel('cos(t)');
plot(t2,y2);
title('cos(t) with sampling rate 0.001');
xlabel('Time in seconds');
ylabel('cos(t)');
plot(t3,y3);
title('cos(t) with sampling rate 0.1');
xlabel('Time in seconds');
ylabel('cos(t)');
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.