# How do I generate sine waves with MATLAB’s max operator and the plot the resulting values in dB versus log frequency? [closed]

I just start learning about matlab. Im very confuse with this. Can anyone gives me such an example solution or any kind of help?

HINT: Put the desired input frequencies in an array and use a for-loop to generate the input sine waves. Store the maximum values of the fIlter’s output in an array for plotting. Plot the 20 log of the output values against the frequency array using the semilogx routine. Frequencies are 2, 10, 15, 20.

1. How can I make for-loop to generate sine waves with values 2, 5, 10 15?
2. How can I input frequencies in an array for 2, 5, 10, 15?
3. What does it mean with store maximum values of the filter’s output in an array?
4. What does it mean with plot against the frequency array using the semilogx routine?
• What's a sine wive? – jojek Aug 16 '18 at 19:30
• Its a combination wave high five. Very popular in American Football. – user28715 Aug 17 '18 at 0:07

Unfortunately, I have some what do you mean myself by your question, so please tolerate my attempt to answer at least some of your questions. The biggest question is what filter?

The first thing to know about Matlab is to avoid loops when you can because it runs faster if you can avoid the loop.

%% Most people like to initialize their work space
clc   %this clears the command line
clear all  %this clears all variables
close all  %this closes all plots
%%   a single percent sign %  is a comment  %% are a special comment that can be used to
%    make pretty printed programs including literate programs
make_an_array=[5 10 15 20];  % I made an array name make_an_array
frequency=make_an_array;  % arrays can be copied
%%  using a loop to make sine waves
time=linspace(0,2,1024);  %sine waves need time, actually angles
sine_by_vector_call=sin(2*pi*frequency(1)*time);  %sine function is called sin
for i=1:length(time)                              % we don't call cos waves virtue waves
sine_by_loop(i)=sin(2*pi*frequency(1)*time(i));
end
%%  we can also make vector calls as vector calls
Out=zeros(length(frequency),length(time));  %Matlab likes you to preallocate memory
%                                            It complains if you don't but
%                                            it runs slower if you don't
for i=1:length(frequency)
Out(i,:)=sin(2*pi*frequency(i)*time);
end
%   If Fortran like loops are your thing
for k=1:length(time)
for i=1:length(frequency)
Out(i,:)=sin(2*pi*frequency(i)*time(k));
end
end
% you can also do it best by
Out=sin(2*pi*frequency'*time);  %make sur you say sin becouse sim gives you a strange error
%   this works because
ft=frequency'*time; % is a matrix
whos % is a good debuging tool
help whos


I'll skip the max and filter part because I don't understand those parts of your question and the plot question also depends on it

you can copy the shaded stuff into your browser and in matlab say

>>edit make_an_array_of_sinewives


and paste it into the editor that just opened

Maybe instructor was talking about the filter and max parts and someone snapchatted you. Isn't that so annoying, you think that what you pay for college, the instructor would stop.

When I was an undergrad, we didn't have Matlab. There was a program called APL that ran on IBM terminals but undergrads didn't get terminal accounts back then unless they really brown-nosed.

We didn't have internet or cell phones either. you would think it was very boring but we didn't have AIDS either, so it wasn't boring at all.