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);endsubplot(1,2,1)plot(n, y);title('y vs n')subplot(1,2,2);plot(ivals, y);title('y vs i'); Related SolutionsMATLAB: Task for generating a wave %Sine wave examplef=3; %frequency [Hz]t=(0:1/(f*100):1);a=2; %amplitude [V]phi=0; %phasey=a*sin(2*pi*f*t+phi); %formulaplot(t,y)xlabel('Time') %labelylabel('Amplitude') %labeltitle('Sine Wave)'); %Title MATLAB: How to generate a sin function of time …. How many samples do you want over that 1024 seconds? Let's say it's 50,000:numSamples = 50000;t = linspace(0, 1024, numSamples);period = numSamples / 8; % Want 8 full cyclesamplitude = 1; % Whatever.y = amplitude * sin(2 * pi * t / period);plot(t, y, 'b-', 'LineWidth', 2);grid on;xlabel('t', 'FontSize', 20);ylabel('y', 'FontSize', 20); Related QuestionCan’t plot convolution
Best Answer