how can i return array range using histogram?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
dpb
el 22 de Jul. de 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 comentarios
dpb
el 23 de Jul. de 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)
Ver también
Categorías
Más información sobre Data Distribution Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!