blanks

3 ビュー (過去 30 日間)
lowcalorie
lowcalorie 2012 年 5 月 23 日
回答済み: Meg Noah 2025 年 8 月 7 日
how would i write a code to print each line of the string array G omitting any trailing blanks?

回答 (2 件)

Wayne King
Wayne King 2012 年 5 月 23 日
s = 'Have you tried deblank? '
s1 = deblank(s);
length(s)
length(s1)

Meg Noah
Meg Noah 2025 年 8 月 7 日
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

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by