How to write Continue Long Statements on Multiple Lines ?

조회 수: 5 (최근 30일)
Vuqar Samedov
Vuqar Samedov 2019년 11월 30일
댓글: Walter Roberson 2019년 12월 1일
formatSpec = '%f%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%f%f%q%q%q%f%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%f%q%q%f%q%q%f%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%C%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%f%q%q%q%q%q%q%q%q%q%q%f%q%q%q%q%q%q%q%q%q%q%q%q%q%q%[^\n\r]';

채택된 답변

Star Strider
Star Strider 2019년 11월 30일
Use repmat to avoid manually typing all 160 of those ‘%q’ repeats!
Try this:
formatSpec = ['%f',repmat('%q',1,160), '%[^\n\r]'];
  댓글 수: 2
Vuqar Samedov
Vuqar Samedov 2019년 11월 30일
How can I write as long as my dear Star Strider friend?
I need to write a long form, but without error.matlab.png
formatSpec = '%f%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%f%f%q%q%q%f%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%f%q%q%f%q%q%f%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%C%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%f%q%q%q%q%q%q%q%q%q%q%f%q%q%q%q%q%q%q%q%q%q%q%q%q%q%[^\n\r]';
Star Strider
Star Strider 2019년 11월 30일
First, use my code, or that of others who have responded to your series of related Questions. They are easier and less prone to error.
Second, it is not possible to break up that long character array into several lines of arbitrary length. Every continued line has to be the same length.

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

추가 답변 (2개)

Walter Roberson
Walter Roberson 2019년 11월 30일
formatSpec = ['%f%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q' ...
'%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q' ...
'%q%q%q%q%q%q%q%f%f%q%q%q%f%q%q%q%q%q%q%q' ...
'%q%q%q%q%q%q%q%q%q%q%q%q%f%q%q%f%q%q%f%q' ...
'%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q' ...
'%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q' ...
'%q%q%q%C%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q' ...
'%q%q%q%q%f%q%q%q%q%q%q%q%q%q%q%f%q%q%q%q' ...
'%q%q%q%q%q%q%q%q%q%q%[^\n\r]' ];
or
formatSpec = "%f%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q" + ...
"%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q" + ...
"%q%q%q%q%q%q%q%f%f%q%q%q%f%q%q%q%q%q%q%q" + ...
"%q%q%q%q%q%q%q%q%q%q%q%q%f%q%q%f%q%q%f%q" + ...
"%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q" + ...
"%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q" + ...
"%q%q%q%C%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q%q" + ...
"%q%q%q%q%f%q%q%q%q%q%q%q%q%q%q%f%q%q%q%q" + ...
"%q%q%q%q%q%q%q%q%q%q%[^\n\r]" ;

Vuqar Samedov
Vuqar Samedov 2019년 12월 1일
Dear friend Walter Roberson,
I am very grateful to you for your help. Thank you very much.

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by