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?

Réponses (1)

You can use celldisp to display a cell, but the result is somewhat verbose, not a nice format.
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]}
C = 1×2 cell array
{[1]} {[2 3]}
fprintf('%d,', C{1}); fprintf('\n')
1,
fprintf('%d,', C{2}); fprintf('\n')
2,3,

Catégories

En savoir plus sur Data Types dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by