コマンドウインドウに配列を要素ごとに表示させる。
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
takeru misawa
le 21 Sep 2021
Commenté : takeru misawa
le 22 Sep 2021
Z = ([1, 2.254, 8]);
fprintf('%g', Z)
でコマンドウインドウの出力結果が
12.2548
となりますが、これを
1 2.254 8
となるようにするにはどのようにするべきでしょうか?
0 commentaires
Réponse acceptée
Atsushi Ueno
le 21 Sep 2021
Z = ([1, 2.254, 8]);
fprintf('%g ', Z)
num2str(Z) % fprintf以外の例
regexprep(num2str(Z),' +',' ') % 空白が多いので一文字にする
Plus de réponses (1)
Atsushi Ueno
le 21 Sep 2021
Modifié(e) : Atsushi Ueno
le 21 Sep 2021
Z = ([1, 2.254, 8]);
Z % これでも「コマンドウインドウに配列を要素ごとに表示」出来るっちゃ出来る
format shortG; % 末尾のゼロを削除する為
Z
2 commentaires
Voir également
Catégories
En savoir plus sur Creating and Concatenating Matrices 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!