声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1283|回复: 0

[编程技巧] sym和vpa

[复制链接]
发表于 2009-3-25 09:28 | 显示全部楼层 |阅读模式

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

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

x
sym和vpa的关系

我在编程时候想得到f(x)的表达式,用x1,x2...,xm表示。其中X是一个已知的n*m的矩阵。a是一个已知的m维向量
sumd=0;
for i=1:m
    x(i)=sym(sprintf('x%i',i));         
end
for i=1:n
    sumd=sumd+a(i)*exp(-(X(i,:)-x)*(X(i,:)-x)'
end
f=1+2*sumd;
运行结果是
??? The following error occurred converting from sym to double:
Error using ==> sym.double
DOUBLE cannot convert the input expression into a double array.
If the input expression contains a symbolic variable, use the VPA function instead.
Error in ==> jqsvm at 71
    x(i)=vpa(sprintf('x56666144',i));
为什么要用VPA函数呢?
回复
分享到:

使用道具 举报

您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

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

GMT+8, 2024-9-22 17:31 , Processed in 0.055918 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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