声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1902|回复: 6

[综合讨论] 求助符号表达式组成的向量,这个错误怎么改?

[复制链接]
发表于 2011-5-16 10:15 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
不怎么懂符号表达式的东西。想得到一个函数组成的向量,程序如下    syms xi;
    for i=1:(n(1)+1)
        fai1(i)=0;
        for p=1:(n(1)+1)
            fai1(i)=fai1(i)+2/n(1)/c1(i)*(1/c1(p)*cos(p*acos(gChebyRoot(i,1)))*cos(p*acos(xi)));
        end
    end



除了xi其他都是数值,想生成fai,一个符号表达式组成的向量。结果有如下错误:


??? The following error occurred converting from sym to double:
Error using ==> sym.double at 29
DOUBLE cannot convert the input expression into a double array.
If the input expression contains a symbolic variable, use the VPA function instead.

回复
分享到:

使用道具 举报

发表于 2011-5-18 00:18 | 显示全部楼层
gChebyRoot ??
 楼主| 发表于 2011-5-19 12:02 | 显示全部楼层
回复 2 # ChaChing 的帖子

呵呵。一个变量。
问题已经解决了。
把fai1(i)=0改成fai1(i)=sym(0)就ok了
发表于 2011-5-19 15:48 | 显示全部楼层
回复 3 # sunhu2003 的帖子

习惯不同, 参考下
syms xi; fai1=sym(zeros(1,n+1));
for i=1:n+1
    for p=1:n+1
            fai1(i)=fai1(i)+2/n/c1(i)*(1/c1(p)*cos(p*acos(gChebyRoot(i,1)))*cos(p*acos(xi)));
    end
end

点评

赞成: 5.0
赞成: 5
学习了,自己在机子上试了下,效率是要高些!  发表于 2011-5-19 22:28
 楼主| 发表于 2011-5-19 16:35 | 显示全部楼层
回复 4 # ChaChing 的帖子

你这是好习惯。呵呵。我是不太懂符号这类东西,所以写出来就有点生硬
发表于 2011-5-19 16:42 | 显示全部楼层
回复 5 # sunhu2003 的帖子

效率会较好些
 楼主| 发表于 2011-5-19 16:44 | 显示全部楼层
回复 6 # ChaChing 的帖子

i see,thanks
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-9-21 12:28 , Processed in 0.053820 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表