MATLAB line continuation within string

前端 未结 3 637
一整个雨季
一整个雨季 2020-12-17 15:29

In MATLAB, ... is used to continue a line to the next line. But if I want to continue a long string within quotation, what can I do? ... will be tr

相关标签:
3条回答
  • 2020-12-17 16:04
    answer=['You can divide strings '...
        ,'by adding a comma '... 
        ,'(as you probably know one year later).'];
    
    0 讨论(0)
  • 2020-12-17 16:12

    If you put the string in brackets, you can build it in several pieces:

    s = ['abc' 'def' ... 
         'ghi'];
    

    You can then split that statement into several lines between the strings.

    0 讨论(0)
  • 2020-12-17 16:23

    You can use strcat or horzcat, which gives you somewhat more options than [], including the ability to mix in variables along with the hardcoded values.

    0 讨论(0)
提交回复
热议问题