time to sample convert

1 Ansicht (letzte 30 Tage)
majid
majid am 14 Jul. 2021
Beantwortet: Kothuri am 23 Aug. 2024
Hi! how can i convert time vector of the following plot to number of sample?
clear all clc set(0,'defaultlinelinewidth',1) True_range=1000;%Range to target el=1.619*10^(-19);%electron charge pulse_width=10e-9; PRF=10;%pulse per second P_avg=0.4; %Average laser power E_t=P_avg/PRF;%energy per pulse in units of joule sigma_w=2e-9; %standard deviation second theta_t=.01; % divergence beam in radiance theta_r=pi;% Reflection angle prom target tau_atm=1;%atmospheric transmission loss tau_opt=1;%reciever optics transmission rho_t=.1;%target reflection reciever_focal=.1;% reciever focal length delta=1e-4;%physical size of the detectorin the ladar recieverin meters dA=(True_range*delta/reciever_focal)^2;%area of target illuminated by light ap_diameter=.01; Rmin=990; minT=Rmin*2/3e8; Rmax=1010; maxT=Rmax*2/3e8; deltat=sigma_w/10; %sample time to ensure good pulse shape sampling t=minT:deltat:maxT; %range of times over which the return signal is measured P_t=(E_t/(sqrt(2*pi)*sigma_w))*exp(-((t-True_range*2/3e8).^2)/(2*sigma_w^2)); I_target=4*tau_atm*P_t/(pi*(True_range^2)*(theta_t^2)); P_ref=I_target*dA*rho_t; %Reflected power I_reciever=tau_atm*P_ref/(theta_r*True_range^2); %intensity at the aperture P_rec= tau_opt*(ap_diameter^2)*pi*I_reciever/4; %recieved signal power after reciever optics % figure; % plot(t,P_rec) % xlabel('Time (sec)') % ylabel('Prec (watt)') % axis tight quantum_eff=.075; h=6.626e-34; v=3e8/1.55e-6; N=P_rec*deltat*quantum_eff/(h*v);%generated photoelectron figure; plot(t,N) xlabel('Time (sec)') ylabel('photon') title('noisless signal') axis tight
  2 Kommentare
KSSV
KSSV am 14 Jul. 2021
Arrange your code properly.
majid
majid am 14 Jul. 2021
oh , I'm sorry.
here the codes:
I want to convert time to sample in the last parameter " signal ".
clear all
clc
set(0,'defaultlinelinewidth',1)
True_range=1000;%Range to target
el=1.619*10^(-19);%electron charge
pulse_width=10e-9;
PRF=10;%pulse per second
P_avg=0.4; %Average laser power
E_t=P_avg/PRF;%energy per pulse in units of joule
sigma_w=2e-9; %standard deviation second
theta_t=.01; % divergence beam in radiance
theta_r=pi;% Reflection angle prom target
tau_atm=1;%atmospheric transmission loss
tau_opt=1;%reciever optics transmission
rho_t=.1;%target reflection
reciever_focal=.1;% reciever focal length
delta=1e-4;%physical size of the detectorin the ladar recieverin meters
dA=(True_range*delta/reciever_focal)^2;%area of target illuminated by light
ap_diameter=.01;
Rmin=990;
minT=Rmin*2/3e8;
Rmax=1010;
maxT=Rmax*2/3e8;
deltat=sigma_w/10; %sample time to ensure good pulse shape sampling
t=minT:deltat:maxT; %range of times over which the return signal is measured
P_t=(E_t/(sqrt(2*pi)*sigma_w))*exp(-((t-True_range*2/3e8).^2)/(2*sigma_w^2));
I_target=4*tau_atm*P_t/(pi*(True_range^2)*(theta_t^2));
P_ref=I_target*dA*rho_t; %Reflected power
I_reciever=tau_atm*P_ref/(theta_r*True_range^2); %intensity at the aperture
P_rec= tau_opt*(ap_diameter^2)*pi*I_reciever/4; %recieved signal power after reciever optics
% figure;
% plot(t,P_rec)
% xlabel('Time (sec)')
% ylabel('Prec (watt)')
% axis tight
quantum_eff=.075;
h=6.626e-34;
v=3e8/1.55e-6;
N=P_rec*deltat*quantum_eff/(h*v);%generated photoelectron
% figure;
% plot(t,N)
% xlabel('Time (sec)')
% ylabel('photon')
% title('noisless signal')
% axis tight
%/////////////////////////////////////////////////
%quantization
A=1; %amplitude of signal
x8=quantBits(N,8,A); %Quantization funcion call
q=2/2^8;
x_8=x8*q;
%/////////////////////////////////////////////////
%shot noise modeled by white noise
SNR=20;
N_shot=awgn(N,SNR,'measured');% white noise adding
%/////////////////////////////////////////////////
M=ones(size(N)); %coherence parameter
x=rand(size(N));
N_speckle=icdf('nbin',x,M,M./(N+M));
%//////////////////////////////////////////////////////////////////////////
kb=1.3806504*10^(-23);
T=300;
C=1e-12;
Q_n_sq=kb*T*C/el;
N_thermal=sqrt(Q_n_sq)*randn(size(N));
%//////////////////////////////////////////////////////////////////////////
S_irr=1000; %watts per square meter per micometer
delta_lam=.001; % bandwidth of reciever micrometer
pbk=S_irr*delta_lam*dA*rho_t*ap_diameter^2/(4*True_range^2); %background power collected by reciever
i_dark=0.75e-9;
N_dark=i_dark*pulse_width/el;
N_b=pbk*pulse_width*quantum_eff*tau_atm*tau_opt/(h*v)+N_dark; %number of photoelectrons from the background
N_back=poissrnd(N_b*ones(size(N)));
%//////////////////////////////////////////////////////////////////////////
sig=sqrt(N.^2+x_8.^2+N_speckle.^2+N_thermal.^2+N_back.^2+N_shot.^2);
signal=(sig-mean(sig));
figure
plot(t.*1000000,signal)
xlabel('Time (microsec)')
ylabel('photon')
title('noisy signal')
axis tight

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Kothuri
Kothuri am 23 Aug. 2024
Hi Majid,
To convert the time vector to samples in the last parameter "signal", you can
  • Calculate the Number of Samples by determining the length of the time vector “t.
  • Create a Sample Index Vector that represents sample indices ranging from 1 to the number of samples.
  • Plot the signal Using Sample index vector as the x-axis
% Calculate the number of samples
num_samples = length(t);
% Create a sample index vector
sample_indices = 1:num_samples;
% Plot the noisy signal using sample indices
figure;
plot(sample_indices, signal);
xlabel('Sample Number');
ylabel('Photon Count');
title('Noisy Signal');
axis tight;
By implementing these changes, you can display the signal data in terms of sample numbers.

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by