【发布时间】:2016-03-25 19:06:55
【问题描述】:
我正在尝试连接字符串,当我像这样单独连接它们时:
strcat({'Plot of f with a plot of iterates for c='},{int2str(c)})
没有错误发生。
但是当我尝试在这样的图形命令中使用它们时:
figure('Name',strcat({'Plot of f with a plot of iterates for c='},{int2str(c)}))
我收到此错误:
Error using figure
Value must be a string
有什么原因吗?
【问题讨论】:
-
您需要了解您的数据类型。
strcat这里的输出是一个单元格,因为您正在传递它的单元格。单元格不是字符串。这里没有理由将单元格传递给strcat。 -
正如@excaza 所说。也不需要
strcat,你可以隐式使用连接:str = ['Plot of f with a plot of iterates for c=', int2str(c)]。
标签: string matlab concatenation matlab-figure string-concatenation