simulink

if i have a simulink model and the output of low pass filter is sin signal with certain frequency if i want to know this frequency and display it on a screen what should i do? remark simulation model time is (inf.)

답변 (2개)

K E
K E 2012년 3월 22일

0 개 추천

I would output the signal to the workspace and calculate the frequency from within Matlab; here is an example approach. You could use Matlab to start your simulation too using the sim command, and afterward plot the spectrum that you calculate.

댓글 수: 8

mohamed  al-asklany
mohamed al-asklany 2012년 3월 23일
i know that .that is easy but the problem i want to calculate frequency not plot it i want to know the frequency of sin signal how many?that is my prob. please if you know help me
K E
K E 2012년 3월 23일
In the example (http://www.mathworks.com/products/matlab/demos.html?file=/products/demos/shipping/matlab/fftdemo.html), the power spectral density Pyy is found. If you have combination of sine waves that make up your signal, Pyy should have peaks at those frequency, and your Matlab routine would identify those peaks. Expanding on the example:
Pyy1 = Pyy(1:128) ;
frequencyOfBiggestPeak = freq(Pyy1 == max(Pyy1)) ; % Hz
mohamed  al-asklany
mohamed al-asklany 2012년 3월 24일
freq() is not a function in matlab
Rick Rosson
Rick Rosson 2012년 3월 24일
freq is an array of frequency values. The idea is to use logical indexing to find the frequency that corresponds to the maximum value of the power spectrum.
mohamed  al-asklany
mohamed al-asklany 2012년 3월 24일
i failed to make it
K E
K E 2012년 3월 26일
You first need to export the simulation time and signal that you want to analyze from Simulink to Matlab using the 'ToWorkspace' block. Once these variables are in the Matlab workspace, set t equal to your simulation time variable and x equal to your simulation signal (for example position). Once you have t and x in your Matlab workspace, follow the example (http://www.mathworks.com/products/matlab/demos.html?file=/products/demos/shipping/matlab/fftdemo.html) to obtain freq and Pyy. Then you can find the peak using the code that I supplied earlier:
Pyy1 = Pyy(1:128) ;
frequencyOfBiggestPeak = freq(Pyy1 == max(Pyy1)) ; % Hz
mohamed  al-asklany
mohamed al-asklany 2012년 3월 27일
my simulink model time is inf
how i can import data from simulink in inf tim?
K E
K E 2012년 4월 4일
You could decide how much time you would need to get a good estimate of the frequency (for example, 30 periods of a 10-second sine wave would be 300 seconds), then put an event listener (http://www.mathworks.com/help/toolbox/simulink/slref/add_exec_event_listener.html) in your model that would output the results to the workspace at 300 seconds.
Sivakumaran Chandrasekaran
Sivakumaran Chandrasekaran 2012년 3월 24일

0 개 추천

I think you can use the option named display which is available in sink block.. I am not sure also whether this will work or not.

댓글 수: 1

mohamed  al-asklany
mohamed al-asklany 2012년 3월 24일
no no no,i want to get freq not to show its spectrum

이 질문은 마감되었습니다.

태그

질문:

2012년 3월 22일

마감:

2021년 8월 20일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by