How to create a text file with indent formatted text

18 ビュー (過去 30 日間)
linda
linda 2022 年 11 月 10 日
回答済み: chrisw23 2022 年 11 月 10 日
Hello everyone, I am creating a gui in which the user provide an input and after clicking a button the output is a text/word file containing indented text. For example, after input a, the output should be “someText” and in the line below, indent “another string”. It should look pretty much like a loop or an indented code in the matlab editor. However, I’m not able to find a smart way to paragraph and indent without writing a ton of code or a variable containing only spaces. Any suggestion? Thanks in advance

回答 (1 件)

chrisw23
chrisw23 2022 年 11 月 10 日
I suggest to use the string data type functionality. Here's an example for Tab and new line options
string(sprintf('\t')) + "myText;" + sprintf('\n') + newline

カテゴリ

Help Center および File ExchangeString Parsing についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by