cell2table not recognizing cell array
11 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
回答(1 个)
Jan
2017-8-9
编辑:Jan
2017-8-9
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 个评论
Stephen23
2017-8-10
编辑:Stephen23
2017-8-10
"...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:
- writetable: no output.
- dlmwrite: no output.
- csvwrite: no output.
- imwrite: no output.
- ncwrite: no output.
- h5write: no output.
- fitswrite: no output.
- multibandwrite: no output.
- audiowrite: no output.
- videoWriter: returns a videoWriter object.
- xmlwrite: returns a serialized DOM node as a character vector.
- writetable: no output.
- xlswrite: returns the status of the write operation... and additionally returns any warning or error message generated by the write operation...
Bonus:
- save: no output.
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
2017-8-10
编辑:Jan
2017-8-10
@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);
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!