how to plot the signal maintained in frequency domain in 3d i tried but as you can see its not what i want :(

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

Answers (2)

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 Comment

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??

Sign in to comment.

"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 Comments

thank you very much for the help how did you come up with the formula? this formula will really help me because the main goal of the whole thing is now to plot in 3d the signal in frequency domain where the signal is written in the form shown image z is from 0 to 10 t from -10 to +10 and the intensity do you think with what you have told me it would work??
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
forgive me mr walter you are right i forgot to change the equation just replace fymax by z/L where L is the length of the fiber consider it 10 can you help me out ?? i am getting this error and i dont know how to fix it matrix dimensions must agree
Please post the current version of your code. The code you have above does not use fymax after it is created.
t=-10:0.1:10;
C=0;
t0=1;
T=t/t0;
A=1+(1i.*C);
fymax=1i;
B=T.^2;
ut=exp((-0.5.*A.*B)+(z*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=-1:0.1:1;
dt = 0.1;
df = 1/(length(ut)*dt);
Fs = 1/dt;
f= -Fs/2+df:df:Fs/2;
plot3(z,f,S)
grid on
axis square

Sign in to comment.

Asked:

on 6 Dec 2013

Commented:

on 7 Dec 2013

Community Treasure Hunt

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

Start Hunting!