필터 지우기
필터 지우기

How to output a cell array using fprintf?

조회 수: 8 (최근 30일)
Sean Murphy
Sean Murphy 2022년 4월 26일
댓글: Sean Murphy 2022년 4월 26일
I am trying to figure out how to output this cell array from Excel using fprintf in my program. I would like to keep the same format. I keep getting errors saying that the function is not defined for cell inputs and get the same using sprintf and I'm not sure on how to convert it
Here is my array in Excel and in MATLAB Command window.
Here is the code I am running to call the program.
The ommision of the semicolon on all outputs the array.
Thank you!
  댓글 수: 1
VBBV
VBBV 2022년 4월 26일
use cell2mat on output and then apply fpritntf

댓글을 달려면 로그인하십시오.

채택된 답변

Chunru
Chunru 2022년 4월 26일
% cell array
a = {'# To Select', 'Names', 'Barcodes', 'Prices'; 1, 'ABC', 1234, 4.5}
a = 2×4 cell array
{'# To Select'} {'Names'} {'Barcodes'} {'Prices'} {[ 1]} {'ABC' } {[ 1234]} {[4.5000]}
fprintf("%s\n", formattedDisplayText(a))
{'# To Select'} {'Names'} {'Barcodes'} {'Prices'} {[ 1]} {'ABC' } {[ 1234]} {[4.5000]}
  댓글 수: 1
Sean Murphy
Sean Murphy 2022년 4월 26일
This works well, thank you for the help!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by