1 m文件调用问题:
Attempt to execute SCRIPT as a function. 只有三个可能:
1 没有这个函数文件,所以自己创建
2 创建文件不在 current directory
3 语法出错 :第一: function 写错为fuction,这个错误,非常容易,就好像main那样的
第二: 其他,文件头的一些不规范写法
但是打入:
>> help wgx.m
No help comments found in wgx.m.
Use the Help browser Search tab to search the documentation, or
type "help help" for help command options, such as help for methods.
>> help hpfilter.m
H=HPFILTER(TYPE,M,N,D0,n)creates the transfer function of a lowpass filter
,H, of the specified TYPE and size (M BY N).To view the filter as an image
or mesh plot ,it should be centered using H=fftshift(H)
valid values for TYPE ,D0 ,AND n are :
\'ideal\'
about IHPF,ideal highpass with cutoff frequency D0,,need not
be supplied,D0 must be positive
这个问题搞得和很乱,不过幸运的是:
错误Attempt to execute SCRIPT my_fun as a function?
新建了一个M文件,内容是
fuction z=my_fun(x);
z=x(1)^2-2*x(1)*x(2)+6*x(1)+x(2)^2-6*x(2);
在work文件夹保存后,在命令窗口中输入 my_fun(【2,3】);
出现??? Attempt to execute SCRIPT my_fun as a function.怎么回事啊?
my god!
function关键字都打错了
于是,按照这个实例搞了一下,成功了:
>> help my_fun
No help comments found in my_fun.m.
Use the Help browser Search tab to search the documentation, or
type "help help" for help command options, such as help for methods.
>> my_fun([2,3])
ans =
-5
>>
但是,自己搞的这个不行:
>> [U,V]=dftuv(8,5);
??? Attempt to execute SCRIPT dftuv as a function.
>>
一查,果然是这个同样错误:fuction [V,U]=dftuv(M,N),汗 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
修改之后,
>> [V,U]=dftuv(8,5);
??? Undefined function or variable "v".
Error in ==> dftuv at 6
idy=find(v>N/2);
>>
再修改,终于成功了
>> [V,U]=dftuv(8,5);
>> d=U.^2+V.^2
d =
0 1 4 4 1
1 2 5 5 2
4 5 8 8 5
9 10 13 13 10
16 17 20 20 17
9 10 13 13 10
4 5 8 8 5
1 2 5 5 2
>> V
V = (8*5)
0 1 2 -2 -1
0 1 2 -2 -1
0 1 2 -2 -1
0 1 2 -2 -1
0 1 2 -2 -1
0 1 2 -2 -1
0 1 2 -2 -1
0 1 2 -2 -1
>> U
U = (8*5)
0 0 0 0 0
1 1 1 1 1
2 2 2 2 2
3 3 3 3 3
4 4 4 4 4
-3 -3 -3 -3 -3
-2 -2 -2 -2 -2
-1 -1 -1 -1 -1
>> M=8;
>> u=0:(M-1);
>> idx=find(u>M/2); %找出u>M/2的索引,所以是6,7,8因为索引是从1开始的
>> idx
idx =
6 7 8
>> u
u =
0 1 2 3 4 5 6 7
>> u(idx)=u(idx)-M;
>> u(idx)
ans =
-3 -2 -1
二十四个冬,二十四个春,二十四个夏,二十四个秋
>> H=lpfilter(\'btw\',65,8,5,2);
>> H
>> H
H =
1.0000 0.9984 0.9750 0.8853 0.7094 0.8853 0.9750 0.9984
0.9984 0.9936 0.9615 0.8621 0.6838 0.8621 0.9615 0.9936
0.9750 0.9615 0.9071 0.7872 0.6098 0.7872 0.9071 0.9615
0.8853 0.8621 0.7872 0.6586 0.5000 0.6586 0.7872 0.8621
0.7094 0.6838 0.6098 0.5000 0.3790 0.5000 0.6098 0.6838
0.5000 0.4804 0.4263 0.3509 0.2710 0.3509 0.4263 0.4804
0.3254 0.3134 0.2809 0.2358 0.1877 0.2358 0.2809 0.3134
0.2065 0.2000 0.1820 0.1567 0.1289 0.1567 0.1820 0.2000
0.1324 0.1289 0.1191 0.1050 0.0890 0.1050 0.1191 0.1289
0.0870 0.0850 0.0796 0.0716 0.0623 0.0716 0.0796 0.0850
0.0588 0.0577 0.0546 0.0500 0.0444 0.0500 0.0546 0.0577
0.0409 0.0403 0.0385 0.0357 0.0322 0.0357 0.0385 0.0403
0.0293 0.0289 0.0277 0.0260 0.0238 0.0260 0.0277 0.0289
0.0214 0.0212 0.0205 0.0193 0.0179 0.0193 0.0205 0.0212
0.0160 0.0158 0.0154 0.0147 0.0137 0.0147 0.0154 0.0158
0.0122 0.0121 0.0118 0.0113 0.0106 0.0113 0.0118 0.0121
0.0094 0.0094 0.0092 0.0088 0.0084 0.0088 0.0092 0.0094
0.0074 0.0074 0.0072 0.0070 0.0067 0.0070 0.0072 0.0074
0.0059 0.0059 0.0058 0.0056 0.0054 0.0056 0.0058 0.0059
0.0048 0.0047 0.0047 0.0045 0.0044 0.0045 0.0047 0.0047
0.0039 0.0039 0.0038 0.0037 0.0036 0.0037 0.0038 0.0039
0.0032 0.0032 0.0031 0.0031 0.0030 0.0031 0.0031 0.0032
0.0027 0.0026 0.0026 0.0026 0.0025 0.0026 0.0026 0.0026
0.0022 0.0022 0.0022 0.0022 0.0021 0.0022 0.0022 0.0022
0.0019 0.0019 0.0019 0.0018 0.0018 0.0018 0.0019 0.0019
0.0016 0.0016 0.0016 0.0016 0.0015 0.0016 0.0016 0.0016
0.0014 0.0014 0.0013 0.0013 0.0013 0.0013 0.0013 0.0014
0.0012 0.0012 0.0012 0.0011 0.0011 0.0011 0.0012 0.0012
0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010
0.0009 0.0009 0.0009 0.0009 0.0009 0.0009 0.0009 0.0009
0.0008 0.0008 0.0008 0.0008 0.0007 0.0008 0.0008 0.0008
0.0007 0.0007 0.0007 0.0007 0.0007 0.0007 0.0007 0.0007
0.0006 0.0006 0.0006 0.0006 0.0006 0.0006 0.0006 0.0006
0.0006 0.0006 0.0006 0.0006 0.0006 0.0006 0.0006 0.0006
0.0007 0.0007 0.0007 0.0007 0.0007 0.0007 0.0007 0.0007
0.0008 0.0008 0.0008 0.0008 0.0007 0.0008 0.0008 0.0008
0.0009 0.0009 0.0009 0.0009 0.0009 0.0009 0.0009 0.0009
0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010
0.0012 0.0012 0.0012 0.0011 0.0011 0.0011 0.0012 0.0012
0.0014 0.0014 0.0013 0.0013 0.0013 0.0013 0.0013 0.0014
0.0016 0.0016 0.0016 0.0016 0.0015 0.0016 0.0016 0.0016
0.0019 0.0019 0.0019 0.0018 0.0018 0.0018 0.0019 0.0019
0.0022 0.0022 0.0022 0.0022 0.0021 0.0022 0.0022 0.0022
0.0027 0.0026 0.0026 0.0026 0.0025 0.0026 0.0026 0.0026
0.0032 0.0032 0.0031 0.0031 0.0030 0.0031 0.0031 0.0032
0.0039 0.0039 0.0038 0.0037 0.0036 0.0037 0.0038 0.0039
0.0048 0.0047 0.0047 0.0045 0.0044 0.0045 0.0047 0.0047
0.0059 0.0059 0.0058 0.0056 0.0054 0.0056 0.0058 0.0059
0.0074 0.0074 0.0072 0.0070 0.0067 0.0070 0.0072 0.0074
0.0094 0.0094 0.0092 0.0088 0.0084 0.0088 0.0092 0.0094
0.0122 0.0121 0.0118 0.0113 0.0106 0.0113 0.0118 0.0121
0.0160 0.0158 0.0154 0.0147 0.0137 0.0147 0.0154 0.0158
0.0214 0.0212 0.0205 0.0193 0.0179 0.0193 0.0205 0.0212
0.0293 0.0289 0.0277 0.0260 0.0238 0.0260 0.0277 0.0289
0.0409 0.0403 0.0385 0.0357 0.0322 0.0357 0.0385 0.0403
0.0588 0.0577 0.0546 0.0500 0.0444 0.0500 0.0546 0.0577
0.0870 0.0850 0.0796 0.0716 0.0623 0.0716 0.0796 0.0850
0.1324 0.1289 0.1191 0.1050 0.0890 0.1050 0.1191 0.1289
0.2065 0.2000 0.1820 0.1567 0.1289 0.1567 0.1820 0.2000
0.3254 0.3134 0.2809 0.2358 0.1877 0.2358 0.2809 0.3134
0.5000 0.4804 0.4263 0.3509 0.2710 0.3509 0.4263 0.4804
0.7094 0.6838 0.6098 0.5000 0.3790 0.5000 0.6098 0.6838
0.8853 0.8621 0.7872 0.6586 0.5000 0.6586 0.7872 0.8621
0.9750 0.9615 0.9071 0.7872 0.6098 0.7872 0.9071 0.9615
0.9984 0.9936 0.9615 0.8621 0.6838 0.8621 0.9615 0.9936
请发表评论