MATLAB Answers

How do I get a histogram of values from within a table?

34 views (last 30 days)
Ashrit Tayade
Ashrit Tayade on 15 Sep 2020
Commented: Vasishta Bhargava on 16 Sep 2020
When I create an array from a select few values from a categorical variable in a table, the histogram shows every variable from the table instead of just the ones in the array.
table1 = table(table.column1 == "CAT", :);
array = table1.column1;
histogram(array)
The code above shows a histogram of the entire column table.column1 instead of a histogram of the array created by using table1.

  0 Comments

Sign in to comment.

Answers (1)

Vasishta Bhargava
Vasishta Bhargava on 16 Sep 2020
Edited: Vasishta Bhargava on 16 Sep 2020
%if true
% code
%end
table1 = table(table.column1=="CAT", :);
histogram(table1(:,1))

  4 Comments

Show 1 older comment
Vasishta Bhargava
Vasishta Bhargava on 16 Sep 2020
Try bar function
% if true
% code
% end
bar(table1(:,1));
Ashrit Tayade
Ashrit Tayade on 16 Sep 2020
Still the same thing. Won't take a table value as an argument.
Vasishta Bhargava
Vasishta Bhargava on 16 Sep 2020
I think your syntax for the table function seems to be invalid It does not return anything to table1. That's why both bar and histogram is giving errors.
See the syntax for table below

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by