4

2行の文を含む文字列を取得します:

'hello this is my first.
program matlab'

そして、文をオンラインで表現するように変更したい:

'hello this is my first.program matlab'

どうすれば matlab でできますか?

4

1 に答える 1

8

\ntoの出現箇所をすべて置換''

   myNewSt = strrep(mySt,sprintf('\n'),'');

たとえば、次のように入力します。

   strrep( sprintf('this is my \n string'),sprintf('\n'),'')
于 2012-06-25T12:27:40.810 に答える