i want to show the signal modulate in simulink but i don't know how to make it
The Spectrum Scope calculates the FFT of the input signal.
In your model you are trying to take the fft of the fft.
(Although you aren't quite doing that as the input to the FFT block needs to be buffered so that the FFT has a vector of data over which to calculate the FFT.)
Remove your FFT and Abs blocks and feed the signal directly into the Spectrum Scope.
Use the block's dialog to set the buffer and FFT length that you want to use.
Phil.
Related
I want to take a wav. file and plot it in Time Domain and Frequency Domain on MATLAB.
I have this code thus far;
[y,fs]=wavread('FireAlarm');
%wavread=the function that is going to read the wav.file
%y=samples
%fs=sampling frequency
%'FireAlarm'=wav file
t=linespace(0,length(y)/fs,length(y));
%linespace=the function that is going to create the time vector
%0=start time
%length(y)/fs=ending time
%length(y)= number of samples in y
plot(t,y)
Nfft=1024;
%Nfft=the length of fft
f=linespace(0,fs,Nfft);
%f= frequency vector
%0=first frequency
%fs=ending frequency
%nfft=length of the frequency vector
G=abs(fft(y,Nfft));
%G= the fft of the samples y in 1024 points
figure;plot(f(1:Nfft/2),G(1:Nfft/2)
Before I can even finish typing the first section, MATLAB tells there is an undefined function or variable 'wavread'.
Anyone know why this may be?
I have a problem in signal processing with Matlab.
I would like to analyze some signal using Matlab but there is a huge difference between the amplitude of signals.
The problem is that the shape of the signal in low amplitude is similar to the shape of the signal in high amplitude. but to analyse the signal, I have to have same range amplitude signal.
how can I have that without destroying the shape and properties of the signal?
Sorry I couldn't send an example plot to clear that.
Something like:
signal1;
signal2;
signal1=(signal1- min(signal1(:))/(max(signal1(:))-min(signal1(:)))
signal2=(signal2- min(signal2(:))/(max(signal2(:))-min(signal2(:)))
% Now both signals are 0-1 range
Without more information this is all what we can offer!
How can I introduce a continuos signal to a MATLAB Function block so I can get a continuos output.
My MATLAB Function block will be this:
function y = fcn(u)
y = 2*exp(-u);
So I can get a negative exponential, this because I need a control voltage source with a negative exponential signal. I need to introduce a controlled voltage source a exponential signal, is there other way?
Thanks
First of all, you don't need a MATLAB function to do that: take your input signal, multiply it by -1 with a Gain block, then use a Math Function block set to exp, and finally another Gain block to multiply it by 2.
Second, your input signal can be whatever you want. For example, you can use a Sine Wave block, or choose whatever block you want from the Sources library. If you leave the Sample Time parameter to 0, you will have a "continuous" signal (in the Simulink sense of the word), see Specify Sample Time in the documentation for more details. You can also use your own data from the MATLAB workspace using a From Workspace block.
So I have the samples (hex values) of a sinus signal and I know the sampling frequency. Using this I can plot an fft or periodogram but then I would like to find out the SNR ratio. What would be the most accurate way to calculate the noise and signal power? I would prefer doing it in frequency domain. Is there a way to do this also in time domain?
Thanks a lot in advance!!!
So if there is noise on your signal and you know that your underlying signal is a sine wave, you can easily get your signal parameters i.e. amplitude,frequency and phase by least squares. If y(t) is your signal just minimize the L2 norm of (y(t)-A.sin(wt+b)) over A,w and b. Then you can easily get signal power from the underlying signal and the noise power from the error signal (y(t)-A.sin(wt+b)).
I'm working on a control system that measures the movement of a vibrating robot arm. Because there is some deadtime, I need to look into the future of the somewhat noisy signal.
My idea was to use the frequencies in the sampled signal and produce a fourier function that could be used for extrapolation.
My question: I already have the FFT of the signal vector (containing 60-100 values e.g.) and can see the main frequencies in the amplitude spectrum. Now I want to have a function f(t) which fits to the signal, removes some noise, and can be used to predict the near future of the signal. How do I calculate the coefficients for the sine/cosine functions out of the complex FFT data?
Thank you so much!
AFAIR FFT essentially produces output as a sum of sine functions with different frequencies. The importance of each frequency is the height of each peak. So what you really want to do here is filter out some frequencies (ie. high frequencies for the arm to move gently) and then come back to the time domain.
In matlab this should be like going through the vector of what you got from fft, setting some values to 0 (or doing something more complex to it) and then use ifft to come back to time domain and make the prediction based on what you get.
There's also one thing you should consider while doing this - Nyquist frequency - this means that the highest frequency that you get on your fft is half of the sampling frequency.
If you use an FFT for data that isn't periodic within the FFT aperture length, then you may need to use a window to reduce spurious frequencies due to "spectral leakage". Frequency estimation techniques to better estimate "between bin" frequency content may also be appropriate. The phase of each cosine sinusoid, relative to the edge of the window, is usually atan2(imag[i], real[i]). The frequency depends on the sample rate and bin number versus the length of the FFT.
You might also want to look into using a Kalman filter instead of an FFT.
Added: If your signal isn't exactly integer periodic in the FFT length, then you may want to do an fftshift before the FFT to move the resulting phase measurement reference point to the center of your data vector, instead of a possibly discontinuous circular edge.