Too many output arguments using histogram function

got a script from someone to calculate SO2 flux from volcanoes using satellite data.
%matS5Pdetect is a matrix (npixel x 14)
matS5Pdetect=[lon1(sel) lon2(sel) lon4(sel) lon3(sel) lat1(sel) lat2(sel) lat4(sel) lat3(sel) SO2VCD(sel) lon5(sel) lat5(sel) secs(sel) row(sel) SO2SCDcor(sel)];
% 1 2 3 4 5 6 7 8 9 10 11 12 13 14
[a, b]=histogram(matS5Pdetect(:,14),50);
[temp, lind]=min(abs(cumsum(a)./sum(a)-0.8));
limitscd=b(lind);% limitscd is the 80 percentile
k=find(matS5Pdetect(:,14)>limitscd); %Based on the 20% largest SO2 slant column, I will estimate a plume direction
if ~isempty(k)
But when I run the code i get this error message:
Error using histogram
Too many output arguments.
Error in S5PSO2_flux_calc_scriptie (line 157)
[a, b]=histogram(matS5Pdetect(:,14),50);
Why does it say too many output arguments? What should i change

1 Comment

Welcom to the forum. I've edited your question to format your code. In the future please use the code/text toggle in rich text editor to format your code.

Sign in to comment.

Answers (2)

The histogram function's documentation page states that it returns at most one output argument.
I think what you're looking for is the histcounts function, whose documentation page shows that the first two outputs (for numeric data) are the bin counts and the vector of edges.
Alternately if you have Statistics and Machine Learning Toolbox available, the prctile function may give you the information you want.
The command histogram replies 1 output only.
Unfortunately in your code the outputs are called "a" and "b", such that I cannot guess, what you expect as output. But maybe you mean histcounts instead of histogram.

Products

Release

R2019b

Asked:

on 25 May 2021

Commented:

on 25 May 2021

Community Treasure Hunt

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

Start Hunting!