Error creating a plot in MATLAB using values I got from excel using actxserver.

90 Views Asked by At

Hello so I am attempting to write a MATLAB script that reads multiple excel files at ones and gathers values from the worksheet. through some research I found that using actxserver is a very quick way to get the data. The values are stored in the out and out1 variables and by using vertcat function I create an array that has all the 300,000 values that I need to store. This seems to work. However when I try to plot the values in a simple x vs y graph using plot I get an error that states:

Error using plot Not enough input arguments.

Error in opener (line 36) plot(out0,out1)

Below is the code. I am sure it is a simple fix but I have looked and not found anything helpful.

  clc;


filename = 'C:\Users\Public\Documents\DASYLab\13.0.0\eng\data\TRIAL\';

D = dir([filename, '\*.csv']);
Num = length(D(not([D.isdir])));

f = Num;
ex = actxserver('excel.application');

o = 0;
k = 0;

for i=1:f



 if(i<=10)
 ex.Workbooks.Open([filename,'mydataIII_0',num2str(i-1)]);
 else 
 ex.Workbooks.Open([filename,'mydataIII_',num2str(i-1)]);
 end

  out0 = get(ex.Range('A8:A40967'),'Value');
  out = vertcat(o,out0);
  o = out;   


  out1 = get(ex.Range('C8:C40967'),'Value');
  outone = vertcat(k,out1);
  k = outone;

end

figure;
plot(out0,out1)

ex.Quit
1

There are 1 best solutions below

0
On

Hello sorry I but I figured it out. The issue was that when the get function was used to get the value it created a cell array.

http://www.mathworks.com/help/matlab/cell-arrays.html

if you want to convert the data to a ordinary array one can use the cell2mat() function