From: dfgdg dfgdfg on
Actually I can do this in workspace with this code;(simple sinus fourier transform)
----------------------------------------------------------------------------------------------------
fo = 4; %frequency of the sine wave in Hz
Fs = 100; %sampling rate in Hz
Ts = 1/Fs; %sampling time interval
t = 0:Ts:1-Ts; %time vector
n = length(t); %number of samples, 100
y = 2*sin(2*pi*fo*t); %the sine curve
%plot the sine curve in the time domain
sinePlot = figure;
plot(t,y)
xlabel('time (seconds)', 'FontWeight','Bold')
ylabel('y(t)', 'FontWeight','Bold')
title('Sample Sine Wave', 'FontWeight','Bold')
set(sinePlot,'Position',[500,500,500,300])
set(sinePlot,'Color',[0.97 0.97 0.97])
grid
freqzExample = figure;
freqRange = -25:1:16; %create a frequency vector from -25 to 16
freqzData = freqz(y,1,freqRange,Fs)/length(y); %get the fourier data
stem(freqRange,abs(freqzData))
xlabel('freq (Hz)', 'FontWeight','Bold')
ylabel('Amplitude', 'FontWeight','Bold')
title('Using the freqz command', 'FontWeight','Bold')
set(freqzExample,'Position',[500,500,500,300])
set(freqzExample,'Color',[0.97 0.97 0.97])
xlim([-25 16]); ylim([0 2]); %set axes limits
grid
----------------------------------------------------------------------------------------------------
But I want to do this process in Simulink.How can I do this process?I have tried some block like FFT,Spectrum scope and spectrum analyzer but I couldn't succeed.
From: Wayne King on
"dfgdg dfgdfg" <sakirae(a)gmail.com> wrote in message <i297dk$bdc$1(a)fred.mathworks.com>...
> Actually I can do this in workspace with this code;(simple sinus fourier transform)
> ----------------------------------------------------------------------------------------------------
> fo = 4; %frequency of the sine wave in Hz
> Fs = 100; %sampling rate in Hz
> Ts = 1/Fs; %sampling time interval
> t = 0:Ts:1-Ts; %time vector
> n = length(t); %number of samples, 100
> y = 2*sin(2*pi*fo*t); %the sine curve
> %plot the sine curve in the time domain
> sinePlot = figure;
> plot(t,y)
> xlabel('time (seconds)', 'FontWeight','Bold')
> ylabel('y(t)', 'FontWeight','Bold')
> title('Sample Sine Wave', 'FontWeight','Bold')
> set(sinePlot,'Position',[500,500,500,300])
> set(sinePlot,'Color',[0.97 0.97 0.97])
> grid
> freqzExample = figure;
> freqRange = -25:1:16; %create a frequency vector from -25 to 16
> freqzData = freqz(y,1,freqRange,Fs)/length(y); %get the fourier data
> stem(freqRange,abs(freqzData))
> xlabel('freq (Hz)', 'FontWeight','Bold')
> ylabel('Amplitude', 'FontWeight','Bold')
> title('Using the freqz command', 'FontWeight','Bold')
> set(freqzExample,'Position',[500,500,500,300])
> set(freqzExample,'Color',[0.97 0.97 0.97])
> xlim([-25 16]); ylim([0 2]); %set axes limits
> grid
> ----------------------------------------------------------------------------------------------------
> But I want to do this process in Simulink.How can I do this process?I have tried some block like FFT,Spectrum scope and spectrum analyzer but I couldn't succeed.

Hi, You can do this with a sine wave block and the spectrum scope block.

In the sine wave block under mask parameters set the sample mode to discrete and enter your parameters as you have done in the MATLAB code. I set them as follows:

Amplitude: 1
Frequency: 4
Phase offset: 0
Sample time: 1/100
Samples per frame: 512

Then connect that block to a Spectrum Scope.

Wayne