matrix points from a plot
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hello!
I got this code below thtr plot some profiles and her maximun value.
I want to have a matrix with the location of the max values for plot it with other varibles.
I mean something like:
Profile max_value depth_location
1 x.xx 15cm
2 x.xxx 10cm
3 x.xxx 20cm
....
[depht_maxvalue] = 15 10 20 ...
load 'biom.txt' % (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;
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')
0 Commenti
Risposte (2)
Sulaymon Eshkabilov
il 24 Giu 2022
What you are trying to attain is to display the found max value and depth location to be displayed in the simulation order:
...
fprintf('Profile max_value depth-location \n')
for i = 1:mm
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), hold on
[x_max,idx] = max(x((i-1)*tl+1:(i-1)*tl+tl,1));
plot(x_max,-biom((i-1)*tl+idx,2),'ro')
fprintf('%d %10.3f %10.0f cm \n',[i, x_max, biom((i-1)*tl+idx,2)])
end
...
0 Commenti
Voss
il 24 Giu 2022
The below includes code for making such a matrix and also a table of the same information (take whichever is more useful):
load 'biom.txt' % (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
summary_matrix = zeros(mm,3);
summary_table = table( ...
zeros(mm,1),zeros(mm,1),zeros(mm,1), ...
'VariableNames',{'Profile' 'max_value' 'depth_location'});
x = 1e6*biom; % <-- here variable concentration microMole => 1e9 miliMol=>1e6
hold on
for i = 1:mm
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));
depth_of_max = biom((i-1)*tl+idx,2); % depth is positive in the summary matrix/table
plot(x_max,-depth_of_max,'ro') % and plotted negative
summary_matrix(i,:) = [i x_max depth_of_max];
summary_table(i,:) = {i x_max depth_of_max};
end
ylim([-50 -10])
xlabel ({'B' ; '(10^6 cells cm^-^2)'}) %label for variable and units
ylabel ({'Depth' ;'(cm)'})
set(gca,'XAxisLocation','top')
disp(summary_matrix);
disp(summary_table);
0 Commenti
Vedere anche
Categorie
Scopri di più su Two y-axis in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!