>> t = [0:0.1:10]; % Declare a time range >> y = sin(t); % Calculate a sine wave - this is your wave in the time domain >> X = fft(y); % Compute the FFT using the Matlab fft function >> Xyy = X.* conj(X) / 101; % Calculate the power spectrum at different frequencies >> f = [0:(2*pi):(2*pi*100)]; % Declare the frequency range >> plot(f,Xyy) % Plot the frequency represenation. You have a spike at a frequency of 2π which is as expected from y = sin(t)
But where should I connect the input and output of Embedded Matlab Function to?You can use User-Defined Functions > Embedded Matlab Function - you can now insert your own m-code as above.
Well your input is the time-domain signal, and the output is the frequency domain signal. For example, if your time-domain signal is stored in an array tdsignal and your frequency-domain signal is stored in an array fdsignal, then your function signature in the m-file should read:But where should I connect the input and output of Embedded Matlab Function to?
I use another method by connecting to FFT block, and then to Spectrum Scope (shown as attached), but not sure whether this is correct. Can you advise me?
|Thread starter||Similar threads||Forum||Replies||Date|
|T||How to plot a margin(matlab) function that is a bode plot in hertz?||Automation, Robotics & Control||0|
|S||Stuck in matlab Simulink simulation diagram using full state feedback||Automation, Robotics & Control||0|
|Hardware Board parameter missing in Matlab simulink||Programming & Languages||0|
|simulink control design||Programming & Languages||2|
|S||Problem with PMSM motor model in Simulink||General Electronics Chat||5|
by Lianne Frith