Maximun value of a different profiles

1 view (last 30 days)
Hello
I have a ploblem finding de maximun values of a data.
I have this input data
load 'biom.dat' (Fortran file output)
wich have 2 columns, concentration and depht. Every column is divided in 20 profiles (1 profile = 10 years) of 201 depht levels. So I have:
load 'biom.dat'
tl=201; % Number of depth levels
[m,n]=size(biom); % derermining the size of the data
mm=m/tl; % total number of profiles
sm=mm; % tottal profiles (for last profile); sm=mm-19; $for all profiles
maxDepth = -400;
Here I plot all the profiles I have in the biom.dat:
nexttile %biom
for i=sm:mm
d=maxDepth ;
hold on
x= 1e6*biom; % <-- here variable concentration microMole => 1e9 miliMol=>1e6
plot(( x ((i-1)*tl+1:(i-1)*tl+tl,1)), (-biom((i-1)*tl+1:(i-1)*tl+tl,2)), 'k', 'LineWidth',1.0)
xlabel ({'B' ; '(10^6 cells cm^-^2)'}) %label for variable and units
ylabel ({'Depth' ;'(cm)'})
set(gca,'XAxisLocation','top')
end
On this point I want to plot the maximun value of every profile and her depht or time step. I mean:
for firts 10 years corresponding to first profile her maximun value;
for firts 20 years corresponding to second profile her maximun value;
...
Someone can help me??
Many thanks!!
  2 Comments
Mathieu NOE
Mathieu NOE on 10 Jun 2022
hello
it would be more efficient if you'd share the data file as well
Ruben Garcia Paba
Ruben Garcia Paba on 10 Jun 2022
Allready added. Note that I change file extention to .txt, but origila is .dat
Thank you!

Sign in to comment.

Accepted Answer

Voss
Voss on 10 Jun 2022
It's not clear why you set sm=mm. That will cause the for loop to iterate once, plotting only the last profile. (Maybe that was done for debugging/testing purposes.) If you allow the for loop to iterate from 1 to mm, then you get all the profiles plotted.
I've done that below, and also added code to find and plot the maximum value of each profile.
% copyfile from txt to dat (only for running here):
copyfile('biom.txt','biom.dat')
load 'biom.dat' % (Fortran file output)
tl=201; % Number of depth levels
[m,n]=size(biom); % derermining the size of the data
mm=m/tl; % total number of profiles
% sm=mm; % tottal profiles (for last profile); sm=mm-19; $for all profiles
% maxDepth = -400;
% I moved this outside the loop:
x= 1e6*biom; % <-- here variable concentration microMole => 1e9 miliMol=>1e6
% nexttile %biom
% for i=sm:mm
for i = 1:mm
% d=maxDepth ;
hold on
plot(( x ((i-1)*tl+1:(i-1)*tl+tl,1)), (-biom((i-1)*tl+1:(i-1)*tl+tl,2)), 'k', 'LineWidth',1.0)
[x_max,idx] = max(x((i-1)*tl+1:(i-1)*tl+tl,1));
plot(x_max,-biom((i-1)*tl+idx,2),'ro')
end
ylim([-50 -10])
xlabel ({'B' ; '(10^6 cells cm^-^2)'}) %label for variable and units
ylabel ({'Depth' ;'(cm)'})
set(gca,'XAxisLocation','top')
  3 Comments
Ruben Garcia Paba
Ruben Garcia Paba on 14 Jun 2022
One last questions, How can have a matrix with the peaks and depth?

Sign in to comment.

More Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

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

Start Hunting!