Azzera filtri
Azzera filtri

cell2table not recognizing cell array

14 visualizzazioni (ultimi 30 giorni)
Aaron Smith
Aaron Smith il 9 Ago 2017
Modificato: Jan il 10 Ago 2017
I am attempting to convert a cell array to a table and then save it as an excel file.
Cell_Array = handles.caIGLs;
i = 1 : numel(Cell_Array);
T = cell2Table(Cell_Array);
Name = 'testdata.xlsx';
XLDoc = xlswrite(Name, T);
Folder = 'C:\Users\c13459232\Documents\MATLAB\Completed code thus far\Results';
file = XLDoc;
save(fullfile(Folder, Name), file);
Using this method, the error that occurs is: Undefined function 'cell2Table' for input arguments of type 'cell'.
Using cell2Table(Cell_Array(i)) the error is: Undefined function 'cell2table' for input arguments of type 'cell'.
Using cell2table(Cell_Array{i}) the error is: Undefined function 'cell2table' for input arguments of type 'double'.
Why is the cell2table function failing to recognize cells as an input?

Risposte (1)

Jan
Jan il 9 Ago 2017
Modificato: Jan il 9 Ago 2017
Matlab is case-sensitive. Some of the error messages contain an upper-case "T" in "cell2Table". Note that the error message does not mean that "cell2table function failing to recognize cells as an input".
Try:
cell2table(Cell_Array)
If this does not word, which Matlab version are you running? Note that this function was introduced in 2013b.
  10 Commenti
Stephen23
Stephen23 il 10 Ago 2017
Modificato: Stephen23 il 10 Ago 2017
"...rather than the new xl spreadsheet that is created by xlswrite as it would be with any of the other commands I've used"
What "other commands I've used" return the data itself after writing this data to file? Is there any MATLAB function that returns the entire data that it has just written to file? Lets have a look at the documentation for all file export functions for standard file formats:
Bonus:
Most of these functions do not have any output at all. What commands have you been using, such that "...that left of the equals sign is different in this case than in any of the other commands I've used" ?
Jan
Jan il 10 Ago 2017
Modificato: Jan il 10 Ago 2017
@Aaron Smith: If foreign people spend their spare time to solve your problem, they will expect, that you took the time to read the documentation at first. It would have been easy for you to find out, that cell2table does not exist in your Matlab version. If you had mentioned the version you are using, I wouldn't post my useless answer.
That xlswrite replies an Excel sheet is a bold speculation. Even if you believe this, you can check this very easily by running the code in the command window:
xlDoc = xlswrite( name, cell array)
You will see immediately, what the output xlDoc is, and then you should start your own investigations at first by reading the docs.
The term "write" means, that the object is written, and not replied.
Your interpretation, that the message "Undefined function 'cell2table' for input arguments of type 'cell'" means, that cell2table "is failing to recognize cells as an input", was a speculation also. This is not a reliable way to program. Read the messages and the docs carefully. Consider, that your local documentation concerns the version, you have installed. Read th online docs to learn something about the current version, consider the "introduced in" information at the bottom. Do not guess, what functions reply, but trust the docs only.
I agree with Stephen. But even if I suggest to improve your programming skills, it is clear that questions about Matlab are welcome in this forum. Your questions can be more efficient and you can invest more effort before, but it is the decision of the ones who answer, if they want to spend their time. So let this encourage you to use the forum more efficiently. Okay?
Create an Excel file:
Folder = 'C:\Users\c13459232\Documents\MATLAB\Completed code thus far\Results';
xlswrite(fullfile(Folder, Name), CellArray);

Accedi per commentare.

Prodotti

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by