0
votes

I have two vectors A = [12 21 23 14 15 36 63 63 .... ] ( of 100 values ) and another vector B = [1:1:100].

Now i want to plot a bar graph such that i can plot the values of A on Y axis for corresponding value from B vector on X -axis. E.g. to plot 12 for 1, 21 for 2 , 23 for 3 and so on.

I tried doing hist(A,B) but it did not work. Let me know some another approach.

2

2 Answers

2
votes

Perhaps you meant to use a regular bar plot:

>> bar(B,A)

If you have too many values on the x-axis, this might produce a nicer plot:

B = 1:100;
A = randi(100,size(B));

bar(B,A,'histc');
xlim([1 100])

bar_plot

0
votes
hist(A,100)

produces a histogram of A, the second parameter is the number of bins that you want. There's some examples in the documentation