cell2table not recognizing cell array
Mostra commenti meno recenti
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)
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
Aaron Smith
il 10 Ago 2017
@Aaron Smith: tables were introduced in R2013b:
The online help is fun to play with, but the only help documentation you should rely on is the help that is part of your installed MATLAB.
In any case it is not required to convert a cell array to a table before saving the data to an excel workbook. Why do you want to perform this step?
You should get used to using the help installed with your version of Matlab ahead of online help. If you do find a solution to something online or end up in the Matlab online help then double check in your local help if the functions exist first. It saves a lot of time. The default online help is always for the latest Matlab.
Unfortunately when it comes to online solutions in fora like this there is often no information as to which version of Matlab is needed for the solution because it is not realistic in many cases. In many cases, when answering a question, people naturally use their knowledge based on whatever version of Matlab they are using. Sometimes we add a comment that the answer only works from a certain version, but often this gets forgotten. A big part of the reason for that is because probably < 1% of people asking questions give information on their Matlab version and it isn't a field to fill in for the question like tags and Products (which also people mostly ignore anyway).
Aaron Smith
il 10 Ago 2017
@Aaron Smith: You have been asking questions on this forum for half a year, which is enough time for you to locate and start reading the MATLAB documentation yourself. I wrote you earlier "You are wasting a lot of your own time by not reading the documentation for functions that you are using". Source:
That was not the only time that you have been advised to read the documentation:
etc, etc.
With that in mind, can you please explain what this code does?:
xlDoc = xlswrite( name, cell array);
Folder = 'C:\Users\c13459232\Documents\MATLAB\Completed code thus far\Results';
file = XLDoc;
save(fullfile(Folder, Name), file);
Aaron Smith
il 10 Ago 2017
Aaron Smith
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:
- 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" ?
@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);
Categorie
Scopri di più su Spreadsheets in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!