How to write Continue Long Statements on Multiple Lines ?
23 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Vuqar Samedov
le 30 Nov 2019
Commenté : Walter Roberson
le 1 Déc 2019
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]';
1 commentaire
Réponse acceptée
Star Strider
le 30 Nov 2019
Try this:
formatSpec = ['%f',repmat('%q',1,160), '%[^\n\r]'];
2 commentaires
Star Strider
le 30 Nov 2019
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.
Plus de réponses (2)
Walter Roberson
le 30 Nov 2019
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]" ;
0 commentaires
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!