how to plot the signal maintained in frequency domain in 3d i tried but as you can see its not what i want :(
Afficher commentaires plus anciens
t=-10:0.1:10;
C=0;
t0=1;
T=t/t0;
A=1+(1i.*C);
fymax=4.5.*pi;
B=T.^2;
ut=exp((-0.5.*A.*B)+(4.5i*pi*exp(-A.*B)));
%-----figure 1--------------
plot(t,abs(ut))
xlabel('normalized time')
ylabel('spectral intensity')
% -----figure 2------------
figure
I=fftshift(fft(ut));
S=I.^2;
plot(abs(S))
xlabel('normalized frequency')
ylabel('spectral intensity')
%%%%
figure
z=-10:0.1:10;
plot3(z,t,S)
grid on
axis square
Réponses (2)
Walter Roberson
le 6 Déc 2013
0 votes
You didn't say anything about what you want it to look like.
Your C is a scalar, so A is a scalar.
Your t0 is a scalar, your t is a vector, so T is a vector, so your B is a vector.
A.*B is scalar times vector, so it is a vector, so both sides of the "+" in the exp() are vectors. So ut is a vector.
With ut being a vector, fft(ut) is a vector, fftshift() of a vector is a vector, so I is a vector. Vector individually squared is vector so S is a vector.
Your z is a vector. Your t is a vector. Your S is a vector. Therefore your plot3() will be a single 3D line, not a surface or a series of mesh lines. Your plot3() is not gaining any visualization power relative to plot(), as the value being plotted (S) in no way depends upon z.
1 commentaire
abed
le 6 Déc 2013
Wayne King
le 6 Déc 2013
Modifié(e) : Wayne King
le 6 Déc 2013
"ok let me ask y ou something different if i want the values of the frequency obtained due to fft but i only have the given as shown in the code the time can i obtain the values of the frequency after the fft?? can u tell me how??"
t=-10:0.1:10;
t0=1;
T=t/t0;
A=1+(1i.*C);
B=T.^2;
ut=exp((-0.5.*A.*B)+(4.5i*pi*exp(-A.*B)));
subplot(211)
plot(t,real(ut)); title('Real Part - ut');
subplot(212)
plot(t,imag(ut)); title('Imaginary Part - ut');
Your signal ut is sampled at time intervals of 0.1 (seconds), so that means the DFT will be periodic in frequency with a period of 10 Hz. The frequency increment (spacing) between the DFT bins is Fs/N where Fs is the sampling frequency - here 10 Hz and the length of the input signal, ut.
figure;
udft = fftshift(fft(ut));
dt = 0.1;
df = 1/(length(ut)*dt);
Fs = 1/dt;
freqvec = -Fs/2+df:df:Fs/2;
plot(freqvec,abs(udft));
xlabel('Hz'); ylabel('|U(f)|');
5 commentaires
abed
le 7 Déc 2013
Walter Roberson
le 7 Déc 2013
What do you intend your "z" to represent? Your calculation so far is only 2 dimensional.
sample number at so many samples per second gives an implied time of sample. FFT switches time to frequency: you do not get both with fft! fft analyzes all of the signal together in order to determine the frequencies.
If you are wanting to show what frequencies are present at which time, then fft is not the proper tool. You need something like a STFT for that. If this is the sort of thing you are looking for, look at the documentation for spectrogram
abed
le 7 Déc 2013
Walter Roberson
le 7 Déc 2013
Please post the current version of your code. The code you have above does not use fymax after it is created.
abed
le 7 Déc 2013
Catégories
En savoir plus sur Transforms dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!