# Find minimum values based on unique number

8 visualizzazioni (ultimi 30 giorni)
DD_2023 il 15 Mag 2024
Commentato: Mathieu NOE il 15 Mag 2024
I have a dataset of temperatures collected over multiple depth profiles (1-147 profiles). The data is all listed in one long table, not by each profile (attached).
Each profile has a different temperature minimum, and I want to find this minimum for each profile, and colour all of the temperatures above this in grey in a figure (essentially discarding them).
1. Evidently I'm going about this the wrong way as my output (T_min) is all the same number (see code below).
2. Once I have the T_min for each profile, when I do a scatter plot, how can I colour each dot less than the T_min - for that particular profile - grey?
Thanks in advance - sorry if this isn't very clear.
j=1;
for i=1:length(dives)
T_min(j) = nanmin(SG579_FINAL_table_MF.Cons_temp(dives));
j=j+1;
end
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Risposta accettata

Mathieu NOE il 15 Mag 2024
hello
the provided mat file contains 492 different profiles (and not 147)
my suggestion so far :
prof = Prof_temp.Profile_num;
prof_unic = unique(prof);
for k=1:length(prof_unic)
ind = (prof == prof_unic(k));
T_min(k) = min(Prof_temp.Temp(ind),[],'omitnan');
end
plot(prof_unic,T_min);
xlabel('Profile #')
ylabel('Average temperature')
##### 10 CommentiMostra 8 commenti meno recentiNascondi 8 commenti meno recenti
DD_2023 il 15 Mag 2024
Thank you! This looks more like what I was expecting. Apologies for my lack of clarity :)
Mathieu NOE il 15 Mag 2024
ok - glad we finally converged to the solution !! :)

Accedi per commentare.

### Più risposte (1)

Stephen23 il 15 Mag 2024
P = 460116x2 table
Profile_num Temp ___________ _______ 1 0.73595 1 0.73338 2 0.73372 2 0.72239 2 0.73413 2 0.7322 2 0.73786 2 0.73755 2 0.73594 2 0.74415 2 0.7336 2 0.72792 2 0.74704 2 0.75886 2 0.75926 2 0.7642
S = groupsummary(P,"Profile_num","min","Temp")
S = 492x3 table
Profile_num GroupCount min_Temp ___________ __________ __________ 1 2 0.73338 2 144 0.65173 3 2 0.73312 4 144 0.69801 5 239 0.36951 6 78 0.35654 7 79 0.70014 8 160 0.66216 9 156 0.013414 10 205 0.013662 11 442 0.00084435 12 626 0.028878 13 705 0.025135 14 959 0.015209 15 683 0.026312 16 915 -0.058026
plot(S.Profile_num,S.min_Temp)
##### 4 CommentiMostra 2 commenti meno recentiNascondi 2 commenti meno recenti
DD_2023 il 15 Mag 2024
Sorry you make an excellent point and have made me realise I've completely messed up my explanation.
T_min for each profile will be located at a certain depth (called Pres, and the T_min Pres will differ between profiles). In the scatter plot of T and S, I wanted to colour any dots shallower than the T_min Pres (differing between profiles) grey.
DD_2023 il 15 Mag 2024
Here are the data for Pres and S

Accedi per commentare.

### Categorie

Scopri di più su Line Plots in Help Center e File Exchange

R2022a

### Community Treasure Hunt

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

Start Hunting!

Translated by