MATLAB: How to plot a family of sine waves ranging from 0.01 to 30 Hz

family of sine waves

I have tried using this:
for i = 1:30;
y(:,i) = sin(2*i*pi*n);
end
But if I give 0.01:30, it gives an error saying values should be integers.

Best Answer

n = sort(randi(50,1,10)); %I don't know what your n is...
ivals = 0.1:30; %did you mean 0:0.1:30 ?
for iidx = 1:length(ivals)
i = ivals(iidx);
y(:,iidx) = sin(2.*i.*pi.*n);
end
subplot(1,2,1)
plot(n, y);
title('y vs n')
subplot(1,2,2);
plot(ivals, y);
title('y vs i');
Related Question