字符串内的MATLAB行连续 [英] MATLAB line continuation within string

查看:98
本文介绍了字符串内的MATLAB行连续的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在MATLAB中,...用于将一行继续到下一行.但是,如果我想在引号中继续使用长字符串,该怎么办? ...将被视为字符串本身的一部分. 使用[]并不是一个完美的解决方案,因为在大多数情况下,我使用sprintf/fprintf来解析长字符串,例如sql查询.使用[]会很麻烦.谢谢.

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 treated as a part of the string itself. Using [] is not a perfect solution since in most cases I use sprintf/fprintf to parse a long string like sql query. Using [] would be cumbersome. thanks.

推荐答案

如果将字符串放在方括号中,则可以将其分成几部分:

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.

这篇关于字符串内的MATLAB行连续的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆