how would i write a code to print each line of the string array G omitting any trailing blanks?

Réponses (2)

Wayne King
Wayne King le 23 Mai 2012

0 votes

s = 'Have you tried deblank? '
s1 = deblank(s);
length(s)
length(s1)
Meg Noah
Meg Noah le 7 Août 2025

0 votes

G = repmat(strcat(" ",datestr(now,'yyyy/mmm/dd HH:MM:SS')," "),10,1)
G = 10×1 string array
" 2025/Aug/07 17:25:59 " " 2025/Aug/07 17:25:59 " " 2025/Aug/07 17:25:59 " " 2025/Aug/07 17:25:59 " " 2025/Aug/07 17:25:59 " " 2025/Aug/07 17:25:59 " " 2025/Aug/07 17:25:59 " " 2025/Aug/07 17:25:59 " " 2025/Aug/07 17:25:59 " " 2025/Aug/07 17:25:59 "
fprintf(1,'%s\n',strtrim(G));
2025/Aug/07 17:25:59 2025/Aug/07 17:25:59 2025/Aug/07 17:25:59 2025/Aug/07 17:25:59 2025/Aug/07 17:25:59 2025/Aug/07 17:25:59 2025/Aug/07 17:25:59 2025/Aug/07 17:25:59 2025/Aug/07 17:25:59 2025/Aug/07 17:25:59

Catégories

En savoir plus sur Characters and Strings dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by