Maximun value of a different profiles

1 次查看(过去 30 天)
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 个评论
Mathieu NOE
Mathieu NOE 2022-6-10
hello
it would be more efficient if you'd share the data file as well
Ruben Garcia Paba
Ruben Garcia Paba 2022-6-10
Allready added. Note that I change file extention to .txt, but origila is .dat
Thank you!

请先登录,再进行评论。

采纳的回答

Voss
Voss 2022-6-10
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 个评论
Ruben Garcia Paba
Ruben Garcia Paba 2022-6-14
One last questions, How can have a matrix with the peaks and depth?

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by