How to generate histogram from a given (x,y) dataset?

4 views (last 30 days)
From a set of x and y values (attached), I am trying to generate a histogram. I want the final plot to look like the one attached.
histogram(data, nbins, 'Binwidth', 2, 'BinLimits',[0,360], 'DisplayStyle','bar','LineStyle','-','FaceColor',[0.6350 0.0780,0.1840]
The data is a 13x2 matrix generated from x and y values. I am not getting the desired result.

Answers (1)

Walter Roberson
Walter Roberson on 21 Sep 2022
filename = '';
data = readmatrix(filename);
bar(data(:,1), data(:,2))
Walter Roberson
Walter Roberson on 29 Sep 2022
userPrompt = {'Enter the outer diameter', 'Enter the inner diameter', 'Enter the number of color sectors', 'Enter the gray level outside the wheel'};
caUserInput = inputdlg(userPrompt, titleBar, 1, defaultValues);
Unless you have reprogrammed inputdlg(), inputdlg() cannot read from an xlsx file.
Earlier the content of the file was described as being x and y values, not as being inner diameters, outer diameters, and grey levels.

Sign in to comment.


Find more on Language Fundamentals in Help Center and File Exchange




Community Treasure Hunt

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

Start Hunting!