How to pick the minimum value from column1(flowrate) with respect to each value from column2(head)?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
muhammad choudhry
le 2 Mar 2022
Commenté : muhammad choudhry
le 2 Mar 2022
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])
0 commentaires
Réponse acceptée
David Hill
le 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 commentaires
David Hill
le 2 Mar 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);
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Annotations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!