How do I linspace this plot?

4 ビュー (過去 30 日間)
Warm Cup
Warm Cup 2019 年 6 月 14 日
編集済み: KALYAN ACHARJYA 2019 年 6 月 14 日
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 件のコメント
KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 6 月 14 日
'm trying to slice a plot into sectors using linspace...slice 2 D Plot?
Warm Cup
Warm Cup 2019 年 6 月 14 日
Yes. I want to make it look like this:1.PNG

サインインしてコメントする。

採用された回答

KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 6 月 14 日
編集済み: KALYAN ACHARJYA 2019 年 6 月 14 日
stem(freq/1e+12,2*abs(X(1:NFFT/2+1)))
Use stem, instead of plot
  2 件のコメント
Warm Cup
Warm Cup 2019 年 6 月 14 日
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 2019 年 6 月 14 日
編集済み: KALYAN ACHARJYA 2019 年 6 月 14 日
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

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by