MATLAB: Compare two vectors having text data

string comparisonvector

I want to compare two matrix A = ['dog', 'cat', 'rabbit'] (1×50 matrix) to a B= 1×2000 matrix which has repetition of elements of A. I want to calculate the frequency of each word ofA in B and plot histograms. strcmp fxn isnot working, i tried others also, please help me with this!! I have assignment submission on thursday 9 feb,2017 please help!!

Best Answer

  • [tf, index] = ismember(B, A);
    That does the matching, and then you can do the histogram on index