How do I average data to produce 1-m interval bins?
Mostra commenti meno recenti
I've got arrays (from text files) of profiles, 1 -> 200m, and back up to the surface, with 40 variables (columns). The data are acquired continuously over depth. I'm looking for a routine that will give me depths at 1-m intervals across all 40 columns, so I end up with arrays of (1:200,1:40). An additional problem is that the profiles vary slightly in near-surface and bottom depths (e.g., 3-197, 2-198, etc), making it a challenge to create arrays of depth v. some variable across all profiles for contouring purposes.
7 Commenti
Star Strider
il 15 Lug 2015
This is obviously dependent on your file, not something any of us can guess. Attach it or a representative sample from it, including any header lines and such. (Use the ‘paperclip’ icon to attach the file.)
John
il 15 Lug 2015
Star Strider
il 15 Lug 2015
No file yet. There are two steps: ‘Choose file’ and then click ‘Attach file’ over on the lower-right of the ‘Attach a <file:’> window.
John
il 15 Lug 2015
Star Strider
il 15 Lug 2015
Modificato: Star Strider
il 15 Lug 2015
No worries. It’s on partially visible in the window on my browser, so it’s not easy to find. I just have experience with Answers, so I know to look for it.
EDIT — Which column is depth? Is Column A just a counter, or does it have other significance?
When I read it with xlsread, it’s a (36x19) double array. (I don’t have 40 columns, but that may not be important.)
John
il 16 Lug 2015
Star Strider
il 16 Lug 2015
That shouldn’t affect my code. I changed it to account for the depth in Col #18, although it ended up in Col 17 in the output of my code, since I deleted Col #1 (a line counter) in the output. You can always put the depth in any column you want. Just change the other column assignments.
If somehow it does affect my code, post a section of your complete data set and I will change my code to accommodate your full-column data file.
Risposta accettata
Più risposte (1)
Guillaume
il 15 Lug 2015
Assuming that each row of your array is of the form:
%depth var1 var2 ... var40
%e.g:
data = [1.1 rand(1,40); %depth is 1.1
2.5 rand(1,40); %depth is 2.5
1.8 rand(1,40); %depth is 1.8
...
]
depths = 1:200
bins = discretize(data(:, 1), depths);
You can then use a for loop to average for each bin:
newdata = zeros(200, 40);
for depth = depths
newdata(depth, :) = mean(data(bins == depth, 2:41));
end
Categorie
Scopri di più su Data Type Conversion in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!