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=1872)

shipf2007 2008-03-26 10:39

【求助】小弟水平很低,谢谢各位了!
 
按照书中的例题写了以下语句
theta=0:0.01:2*pi
rho=sin(2*theta).*cos(2*theta)
polar(theta,rho,'k')
可却不能通过
错误提示为:
[COLOR="Red"]??? Attempt to execute SCRIPT polar as a function.

Error in ==> polar at 3
polar(theta,rho,'k')[/COLOR]
还有下面的这个
x=linspace(0,2*pi,60)
y=sin(x)
z=cos(x)
t=sin(x)./(cos(x)+eps)
ct=cos(x)./(sin(x)+eps)
subplot(2,2,1)
plot(x,y)
subplot(2,2,2)
plot(x,z)
subplot(2,2,3)
plot(x,t)
subplot(2,2,4)
plot(x,ct)
错误提示为:
[COLOR="red"]??? Attempt to execute SCRIPT subplot as a function.

Error in ==> subplot at 6
subplot(2,2,1)[/COLOR]
每次练习使用一个新的函数都提示错误,我实在是不明白为什么,希望高人指点,不胜感激!

shiqiang 2008-03-26 11:32

以上两个程序我都验证过了,没有问题。

shipf2007 2008-03-26 11:54

我是把上面的语句先写到一个m文件里,然后调用那个m文件,结果就是提示出错的。我实在是不知道自己犯了什么低级错误:cry:

shipf2007 2008-03-26 12:06

我还是描述一下我的具体过程,麻烦大家看看:
1、在matlab主窗口里点击“新建”图标,新建了一个空白的m文件;
2、在空白的m文件里写下上面的语句,然后保存,比如命名为a.m点击“运行”图标;
3、回到主窗口,在运行结果处显示如下:
[COLOR="Red"]??? Attempt to execute SCRIPT subplot as a function.

Error in ==> subplot at 6
subplot(2,2,1)[/COLOR]
4、本人不死心,在主窗口输入命令a,然后回车,结果同上!
:ft:
想哭!大家帮帮忙啊

fgabertb 2008-03-26 12:53

剛剛也是照你的方法 弄成m
執行也是沒問題:rolleyes:

dnping 2008-03-26 14:10

看下你的matlab是否有问题。
你的函数是没有问题的。

shipf2007 2008-03-26 15:44

真郁闷!但是在这里谢谢大家的帮助,谢谢了!

shipf2007 2008-03-26 17:05

我犯了低级错误,借鉴
 
我是一个初学者,在练习使用函数时,为了图省事,就把写的m文件命名为所练习的函数的名字,结果就出现了上面的问题,希望能够成为前车之鉴。
同时再次谢谢无私帮助我的人们!


所有时间均为北京时间。现在的时间是 03:17

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