필터 지우기
필터 지우기

How to reuse the same format

조회 수: 2 (최근 30일)
Tianyi Yu
Tianyi Yu 2019년 11월 23일
편집: Tianyi Yu 2019년 11월 26일
For example, this code has nine "%7.0f" and one "%5.0f". Is there any way I can simplify this code, like "repmat('%7.0f' , 9)" , but still have the "defaults->" in the front?
fprintf('defaults-> %5.0f%7.0f%7.0f%7.0f%7.0f%7.0f%7.0f%7.0f%7.0f%7.0f\n' , header')

채택된 답변

Tianyi Yu
Tianyi Yu 2019년 11월 23일
OK i think i solved this problem already:
fmt = ['# defaults-> %5.0f',repmat('%7.0f',1,8),'%7.0f\n',];
fprintf(fmt,header);

추가 답변 (1개)

Stijn Haenen
Stijn Haenen 2019년 11월 23일
Maybe this will work:
a='%7.0f';
fprintf(strcat('defaults->',repmat(a,1,9),'\n'),header);

카테고리

Help CenterFile Exchange에서 MATLAB Coder에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by