How do I linspace this plot?

5 visualizaciones (últimos 30 días)
Warm Cup
Warm Cup el 14 de Jun. de 2019
Editada: KALYAN ACHARJYA el 14 de Jun. de 2019
I'm trying to slice a plot into sectors using linspace. This is the code I'm using:
c = 3e+8; % Speed of light [m/sec]
lambda = 1665e-9; % Wavelength [nm]
freq = c/lambda; % Actual Frequency of light [THz]
fsamp = freq*10; % Sampling frequency
fs = 1/fsamp; % Unit time [fs]
Ls = 200; % Length of signal
sig = 8e-15; % Pulse duration
ts = (0:Ls-1)*fs; % Time base
t0 = max(ts)/2; % Used to centering the pulse
Egauss = (exp(-2*log(2)*(ts-t0).^2/(sig)^2)).*cos(-2*pi*freq*(ts-t0));
subplot(2,1,1)
plot(ts/1e-15,real(Egauss),'b');
title(['Gaussian Pulse \sigma=', num2str(sig),'s']);
xlabel('Time (fs)');
ylabel('Amplitude');
ylim([-1 1])
%xlim([30e-15 70e-15])
grid on
NFFT = 2^nextpow2(Ls);
X = fft(Egauss,NFFT)/Ls;
freq = 0.5*fsamp*linspace(0,1,NFFT/2+1); % (full range) Frequency Vector
subplot(2,1,2)
plot(freq/1e+12,2*abs(X(1:NFFT/2+1)))
title('Magnitude of FFT');
xlabel('Frequency (THz)')
ylabel('Magnitude |X(f)|');
xlim([65 300])
grid on
%f = linspace(60*10^12,280*10^12,1000)';
I need to get a 1000 frequency slices from 'freq' plot that starts from 60 to 280 THz. How do I linspace the frequency domain of the gaussian pulse(fft of the time domain)?
  2 comentarios
KALYAN ACHARJYA
KALYAN ACHARJYA el 14 de Jun. de 2019
'm trying to slice a plot into sectors using linspace...slice 2 D Plot?
Warm Cup
Warm Cup el 14 de Jun. de 2019
Yes. I want to make it look like this:1.PNG

Iniciar sesión para comentar.

Respuesta aceptada

KALYAN ACHARJYA
KALYAN ACHARJYA el 14 de Jun. de 2019
Editada: KALYAN ACHARJYA el 14 de Jun. de 2019
stem(freq/1e+12,2*abs(X(1:NFFT/2+1)))
Use stem, instead of plot
  2 comentarios
Warm Cup
Warm Cup el 14 de Jun. de 2019
Thanks. But how do I increase the number of discrete lines in the plot? I'm also trying to get the value of each discrete line, similar to linspace.
KALYAN ACHARJYA
KALYAN ACHARJYA el 14 de Jun. de 2019
Editada: KALYAN ACHARJYA el 14 de Jun. de 2019
reduce fsamp, like as follows
fsamp = freq*5; % Sampling frequency;
%............^ I hav decresed this value from 10 to 5, check it.
For second question get the value, add the following line at end on the code
disp(2*abs(X(1:NFFT/2+1)));
Run it and check in command window

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Surface and Mesh Plots en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by