Display a cell in an fprintf?
Show older comments
I'm using an array from an Excel spreadsheet, and am trying to display a 1x1 cell output. However, fprintf doesn't support cell array arguments. When I use it, I get the message,
"Error using fprintf
Function is not defined for 'cell' inputs."
Is there another function I could use to display the cell? Or would I need to convert it to another form before I can use it?
Answers (1)
What you would normally do with a cell and fprintf() is dereference the cell into its contents. Watch out that if you have fewer % format items than entries in the matrix that the format will be repeated as many times as required to output all of the items.
C = {[1], [2 3]}
fprintf('%d,', C{1}); fprintf('\n')
fprintf('%d,', C{2}); fprintf('\n')
Categories
Find more on Data Types in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!