MATLAB Answers

how to plot the data in a cell array

51 views (last 30 days)
Nicolas
Nicolas on 26 Jul 2013
I'm writing a program in order to calculate the time of appearance of each word in a txt document(a novel, for about 300,000 words).The result will be stored in a cell array. Besides, I need to plot the curve, the axes should be "time of appearance" and "range of time of appearance".
But I don't know how to plot this curve. I hope there's someone can offer me some help.

  0 Comments

Sign in to comment.

Answers (2)

Nathan Crosty
Nathan Crosty on 26 Jul 2013
It sounds like you are looking for the cell2mat function. This will convert a cell array to numeric array which you can use to plot.

  1 Comment

Nicolas
Nicolas on 29 Jul 2013
Thank you! I just found what you said.

Sign in to comment.


Azzi Abdelmalek
Azzi Abdelmalek on 26 Jul 2013
s={'one','two','one','three','one','four','one','two'}
[a,b,c]=unique(s,'stable')
n_occ=accumarray(c,1)
out=[a' num2cell(n_occ)]
bar(n_occ)
set(gca,'xticklabel',a)

  1 Comment

Nicolas
Nicolas on 29 Jul 2013
Thank you! I tried your way, it works.

Sign in to comment.

Sign in to answer this question.