MATLAB Answers

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

3 views (last 30 days)
abed
abed on 6 Dec 2013
Commented: abed on 7 Dec 2013
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

  0 Comments

Sign in to comment.

Answers (2)

Walter Roberson
Walter Roberson on 6 Dec 2013
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

abed
abed on 6 Dec 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??

Sign in to comment.


Wayne King
Wayne King on 6 Dec 2013
Edited: Wayne King on 6 Dec 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 Comments

Show 2 older comments
abed
abed on 7 Dec 2013
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
abed
abed on 7 Dec 2013
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.

Community Treasure Hunt

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

Start Hunting!