Bin X data, sum corresponding Y data and then plot.
5 visualizzazioni (ultimi 30 giorni)
I have X data ranging from 0 to 999 and corresponding Y data. I want to bin the X data from 0 to 2000 with a bin size of 10. Then accumulate corresponding Y data in the respective bins. For example, X data from 0.1 to 10 should be taken as 10; 10.01 till 20 should be taken as 20 etc. The Y data in the same interval should be summed up and put in the corresponding bins. At the end, I want to plot X,Y . Please help me to code this... thank you.
Più risposte (1)
Jan il 3 Ago 2015
edges = [0.1, 10, 20]; % However you define this...
[N, edges, bin] = histcounts(X, edges);
Result = accumarray(bin, Y);
I cannot check this currently. Perhaps you have to transpose an input of accumarray.