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

1 view (last 30 days)
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])

Accepted Answer

David Hill
David Hill on 2 Mar 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 Comments

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by