How to pick the minimum value from column1(flowrate) with respect to each value from column2(head)?

1 visualización (últimos 30 días)
Hi,
I have a data in 2 columns. Column 1 is flowrate and column 2 is head. Head values are like 0,0,0.01,0.01, and up to 0.5 but with respect to head values flow rate values changing even with at the same head
for example:
Head Flowrate
0.5 5.04
0.5 5.15
0.5 5.12
etc etc
I want to plot the graph of head over flowrate by specifying that for each head value plot the minimum flowrate value for example if at 0.5 head flowrate have a range from (5.04-5.12) it will plot 5.04... This way I can ignore the discrepencies and analyse the data.
Below is the code for only plotting the data but not with the minimum flow rate value, I am also attaching the csv file. Your help will be much appreciated.
Code so far:
files = ['F:\19-CFD_Analysis\LES\K-Equation\110_Outlet\Fine_1\S_Curve\S-Curve.csv'];
a = readmatrix(files);
x=a(:,1);
y=a(:,2)*1000;
plot(x,y,'*')
xlim([0 6])
ylim([0 500])

Respuesta aceptada

David Hill
David Hill el 2 de Mzo. de 2022
s=readmatrix('S-Curve.csv');
a=[];
u=unique(s(:,2));
for k=1:length(u)
m=min(s(s(:,2)==u(k),1));
a=[a,m(1)];
end
plot(u,a);
  3 comentarios
David Hill
David Hill el 2 de Mzo. de 2022
This is better.
s=readmatrix('S-Curve.csv');
u=unique(s(:,2));
a=zeros(1,length(u));%preallocate
for k=1:length(u)
a(k)=min(s(s(:,2)==u(k),1));%s(:,2)==u(k) finds all column 2 values equal to u(k), then min(s(that,1)) finds min of all column 1 rows that correspond
end
plot(u,a);

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Multidimensional Arrays en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by