Search code examples
arraysmatlabplotcell-array

Plotting the cell array in MATLAB


I have two 1-D cell arrays with numbers inside, how can I plot this?

X = {'1' '2' '35' }
Y = {'23' '30' '90' }

I am trying to plot the two cell arrays using plot command:

plot (X,Y);

And I received the following the error:

Not enough input arguments. 

Any suggestions?


Solution

  • You need to first convert your cell arrays of strings to an array of numbers. You can do this using str2double

    X = {'1' '2' '35' }
    Y = {'23' '30' '90' }
    
    plot(str2double(X), str2double(Y))
    

    enter image description here