How do I use fprintf to print a cell in a cell array?

Say I have a 1x1 cell array with the cell containing "Hi"
How do I use fprintf and this cell array in a script to print "Hi" in the command window?

Answers (2)

Use curly braces {} to address the cell array:
c = {"Hi"}; % String Variable
fprintf('%s',c{:})
Hi
c = {'Hi'}; % Character Vector
fprintf('%s',c{:})
Hi
.

Categories

Products

Release

R2021b

Asked:

on 31 Mar 2022

Edited:

on 31 Mar 2022

Community Treasure Hunt

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

Start Hunting!