Finding the maximum point of my plot

I wrote a code that gives me two different plots and I was trying to find the x and y numbers for the peak of my second graph. Any idea how to go about finding the maximum y and its x position?
Here is my full code
% CEIE 355
% RIVER POLLUTION
% Problem:
% You want to provide decision makers with the best estimate of the
% pollutant concentration in a river at different downstream distances
% to give them info on which to base their decisions for water quality management.
% The average flow velocity is 0.305 m/s. At the source, the BOD
% concentration is 10.0 mg/L and the dissolved oxygen deficit is 0.0 mg/L.
u= 0.305 ; % m/s
L0= 10 ; % mg/L
D0=0 ; % mg/L
% From field sampling, deoxygenation (kd) and reaeration (ka) rate constants are:
kd=0.6 ; % day^(-1)
ka=2.0 ; % day^(-1)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Run the S-P model to obtain BOD concentration (L) and D.O. deficit (D)
% in the river as a function of downstream distance
distance=0:200; %km
L(1)=L0; % mg/L BOD concentration at the source (distance=0, x=1)
D(1)=D0; % mg/L D.O. deficit at the source (distance=0, x=1)
for x=2:length(distance) % loop over space (downstream distance)
L(x)=L(1)*exp(-kd*distance(x)/u/86.4);
D(x)=D(1)*exp(-ka*distance(x)/u/86.4)+(kd*L(1)/(ka-kd))*(exp(-kd*distance(x)/u/86.4)-exp(-ka*distance(x)/u/86.4));
end
%%%%%%%
% Plotting Commands
% plot L
figure
plot(distance ,L )
xlabel ' Distance '
ylabel ' Concetration of BOD (L) '
% plot D
figure
plot(distance , D )
xlabel ' Distance '
ylabel ' Dissolved Oxygen Deficit (D) '

回答(1 个)

KSSV
KSSV 2019-3-1
Read about function max. It gives you the maximum value and its index also.

类别

在 帮助中心 和 File Exchange 中查找有关 Biological and Health Sciences 的更多信息

标签

回答:

2019-3-1

Community Treasure Hunt

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

Start Hunting!

Translated by