MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   MATLAB论坛 (https://www.labfans.com/bbs/forumdisplay.php?f=6)
-   -   谁帮我纠下错误 (https://www.labfans.com/bbs/showthread.php?t=2381)

pang007 2008-04-18 17:26

谁帮我纠下错误
 
str=[' the value of pi ='num2str(pi)];
disp(str)


本人认为是对的为什么不能执行。

watcher 2008-04-18 18:58

[QUOTE=pang007;8876]str=[' the value of pi ='num2str(pi)];
disp(str)


本人认为是对的为什么不能执行。[/QUOTE]

matlab将字符串中的每个字符作为元素,按照行向量的形式存储字符串,参照行向量的规则进行向量的运算。num2str返回一个新的字符串,将两个字符串相连时,除了使用matlab现有的函数外(具体名字忘了),在运用lz的格式时,应该使用行向量相连的规则,在两个向量间使用空格或“,”分隔开。

以下为正确格式:
str=[' the value of pi =' num2str(pi)];

str=[' the value of pi =',num2str(pi)];

pang007 2008-04-18 19:05

太谢谢你了
 
谢谢你的热心帮助


所有时间均为北京时间。现在的时间是 12:35

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.