声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1363|回复: 7

[编程技巧] 一个小问题,请各位帮忙解决

[复制链接]
发表于 2006-10-10 20:57 | 显示全部楼层 |阅读模式

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

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

x
>> [x,y,z,v] = reducevolume(x,y,z,v,2);
??? Attempt to execute SCRIPT reducevolume as a function.  怎么解决这个问题?
回复
分享到:

使用道具 举报

发表于 2006-10-10 21:15 | 显示全部楼层
原帖由 xinqing2004 于 2006-10-10 20:57 发表
>>  = reducevolume(x,y,z,v,2);
??? Attempt to execute SCRIPT reducevolume as a function.  怎么解决这个问题?



reducevolume是你自己定义的函数吗?
 楼主| 发表于 2006-10-10 21:45 | 显示全部楼层

不是的

不知道怎么回事,以前都没有遇到这个问题,今天怎么就老出现
举个例子:
>> t = (1/16:1/8:1)'*2*pi;
>> x = sin(t);
>> y = cos(t);
>> fill(x,y,'r')
??? Attempt to execute SCRIPT fill as a function.
很奇怪! 怎么说fill 是个SCRIPT?
 楼主| 发表于 2006-10-10 22:26 | 显示全部楼层
我如果把这些语句先放在m文件里执行,出现??? Attempt to execute SCRIPT fill as a function.警告句之后,再放入命令栏里直接一条一条执行就会出现这种情况。以前都是可以在命令栏里执行的,不知道为什么会出现这种现象?:'(
发表于 2006-10-10 22:30 | 显示全部楼层
你用的是什么文件名,fill吗
这个是不能用的,是的话,换一个吧
>> which fill all
F:\MATLAB7\toolbox\matlab\specgraph\fill.bi
把除了上面的其他的删除掉,保存为其他的m文件名再试试

[ 本帖最后由 jimin 于 2006-10-10 22:32 编辑 ]

评分

1

查看全部评分

发表于 2006-10-10 22:41 | 显示全部楼层
重名?
下面是我在matlab主页上找到的
Subject:
Why do I receive the error "Attempt to execute SCRIPT as a function" ?

Problem Description:
I receive the error:
??? Attempt to execute SCRIPT untitled as a function.


Solution:
This error results because there is a script M-file named <filename> and your calling syntax requires that this script either takes arguments or returns values, which are properties of a function and not of a script.

This can happen because there is a script <filename> and a function <filename> that both exist on the path. If the script appears before the function on the path, then your commands will attempt to use it instead of the function. You may use the command:

which <filename>

to determine which instance of <filename> that MATLAB is attempting to call. If you want to see all instances of a function on the path, type the command:

which <filename> -all

Alternatively, such behavior may occur in certain scenarios where your filename contains invalid characters. In particular, you may see this error if the filename contains characters that are MATLAB operators such as -, +, or *. M-file filenames must begin with a letter, which may be followed by any combination of letters, digits, and underscores.

评分

1

查看全部评分

 楼主| 发表于 2006-10-12 20:56 | 显示全部楼层
谢谢各位的帮助!
发表于 2006-10-12 21:26 | 显示全部楼层
本论坛高手很多啊,呵呵
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

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

GMT+8, 2024-10-4 03:27 , Processed in 0.053961 second(s), 20 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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