How to enter a cell array into an fprintf statement

조회 수: 15 (최근 30일)
Allisa Baines
Allisa Baines 2018년 3월 5일
답변: Walter Roberson 2018년 3월 5일
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.

답변 (1개)

Walter Roberson
Walter Roberson 2018년 3월 5일
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{:});

카테고리

Help CenterFile Exchange에서 Cell Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by