how do I find at which sample on the x-axis I have maximum value of y-axis?

7 views (last 30 days)
Hi! I want to determine that at which sample on the x-axis I have maximum value of y-axis. I will appreciate if some one could help me?
here is my code :
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
quantum_eff=.075;
h=6.626e-34;
v=3e8/1.55e-6;
N=P_rec*deltat*quantum_eff/(h*v);%generated photoelectron
figure;
plot(N,'b.-')
N_max=max(N);
%which sample?

Accepted Answer

the cyclist
the cyclist on 23 Jul 2021
If you use the two-output syntax for the max() function, the second output is the index of the maximum:
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
quantum_eff=.075;
h=6.626e-34;
v=3e8/1.55e-6;
N=P_rec*deltat*quantum_eff/(h*v);%generated photoelectron
figure;
plot(N,'b.-')
% Changed this line to output index:
[N_max,index_of_N_max]=max(N);
sprintf('Maximum of N occurred at index position %d.',index_of_N_max)
ans = 'Maximum of N occurred at index position 334.'

More Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!