how can i return array range using histogram?
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
i have a Netcdf file including latitude(30619x1), altitude(150), N2O(150x30619) and other information. i have made a histogram using below code:
clc;
clear all;
ncdisp('ACEFTS_v3p5_N2O.nc')
T = ncread('ACEFTS_v3p5_N2O.nc','N2O',[1 1], [Inf Inf], [1 1]);
alt= ncread('ACEFTS_v3p5_N2O.nc','altitude',[1], [Inf], [1]);
lat= ncread('ACEFTS_v3p5_N2O.nc','latitude',[1],[Inf], [1]);
flag= ncread('ACEFTS_v3p5_N2O.nc','quality flag',[1 1], [Inf Inf], [1 1]);
er=ncread('ACEFTS_v3p5_N2O.nc','N2O error',[1 1], [Inf Inf], [1 1]);
fclose('all')
lat_inrange_1 = lat >= 15 & lat < 26; %watch the edge conditions!
lat_inrange_2 = lat >= 41 & lat < 46; %watch the edge conditions!
lat_inrange_3 = lat >= 71 & lat < 81;
lat_inrange = lat_inrange_1 | lat_inrange_2|lat_inrange_3;
T_1 = T(:,lat_inrange);
% latbin=(15:5:80);
latbin_1 =(15:5:26);
latbin_2=(41:5:46);
latbin_3=(65:5:70);
latbin_4=(71:5:81);
binedges = datenum(latbin_1:latbin_2:latbin_3:latbin_4);
[~,L] = histc(lat,binedges);
now i want to return the latitude range based on L. how can i do that?
thank you
0 Kommentare
Antworten (1)
dpb
am 22 Jul. 2015
Can't (at least if you mean by "range" the max/min difference of observed values in the data vector); the second return value from histc only tells you which bin each element of the vector belongs to; you would still have to search within it excepting as a indirect search instead of directly. Don't try to be cute, just write
latRnge=max(lat)-min(lat);
or whatever it is that is your definition if that isn't it.
2 Kommentare
dpb
am 23 Jul. 2015
That'd be the L(45) value; the bin in which the 45th element went. The magnitude of that bin would be between the two edges in the edges vector of that value:value+1. That is, if it were to be 8, say, it would be between edges(8:9)
Siehe auch
Kategorien
Mehr zu Data Distribution Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!