How to enter a cell array into an fprintf statement

15 visualizaciones (últimos 30 días)
Allisa Baines
Allisa Baines el 5 de Mzo. de 2018
Respondida: Walter Roberson el 5 de Mzo. de 2018
I am trying to enter this cell array
Status={'s','Heat','Light','Off'}
into an fprintf statement because i need it to print
fprintf('For %0.0f Kelvin and %0.0f lux, the device is in mode ____',TK,TI,_____)
I already know the value of TK and TI I just need to know how to format the first blank space so that the mode from the cell array status appears.

Respuestas (1)

Walter Roberson
Walter Roberson el 5 de Mzo. de 2018
data_to_print = [num2cell(TK(:)), num2cell(TI(:)), Status(:)] .'; %transpose is important
fprintf('For %0.0f Kelvin and %0.0f lux, the device is in mode %s\n', data_to_print{:});

Categorías

Más información sobre Cell Arrays en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by