matlab代码运行的问题
运行以下求解最大李雅普诺夫指数的程序是,总是提示: ??? Undefined function or variable 'P'.请问如何解决这个问题。程序代码如下:function lambda_1=largest_lyapunov_exponent(data,N,m,tau,P)%the function is used to calcultate largest lyapunov exponent with the
%mended algorithm,which put forward by lv jing hu.
%data:the time series
%N:the length of data
%m:enbedding dimention
%tau:time delay
%P:the mean period of the time series,calculated with FFT
%lambda_1:return the largest lyapunov exponent
%skyhawk
delt_t=1;
Y=reconstitution(data,N,m,tau );%reconstitute state space
M=N-(m-1)*tau;%M is the number of embedded points in m-dimensional space
for j=1:M
d_max=1e+100;
for jj=1:M %寻找相空间中每个点的最近距离点,并记下
d_s=0; %该点下标
if abs(j-jj)>P %限制短暂分离
for i=1:m
d_s=d_s+(Y(i,j)-Y(i,jj))*(Y(i,j)-Y(i,jj));
d_min=d_max;
if d_s<d_min
d_min=d_s;
idx_j=jj;
end
end
end
end
% index(j)=idx_j;
max_i=min((M-j),(M-idx_j));%计算点j的最大演化时间步长i
for k=1:max_i %计算点j与其最近邻点在i个离散步后的距离
d_j_i=0;
for kk=1:m
d_j_i=d_j_i+(Y(kk,j+k)-Y(kk,idx_j+k))*(Y(kk,j+k)-Y(kk,idx_j+k));
d(k,j)=d_j_i;
end
end
end
%对每个演化时间步长i,求所有的j的lnd(i,j)平均
=size(d);
for i=1:l_i
q=0;
y_s=0;
for j=1:l_j
if d(i,j)~=0
q=q+1;
y_s=y_s+log(d(i,j));
end
end
y(i)=y_s/(q*delt_t);
end
x=1:length(y);
pp=polyfit(x,y,1);
lambda_1=pp(1);
yp=polyval(pp,x);
plot(x,y,'-o',x,yp,'--')本人的版本为64位win7,matlab7.6.0(R2008a) P 是函数的输入之一,用的时候没有赋值 {:{27}:}木有看出来 321forever 发表于 2013-10-30 14:57 static/image/common/back.gif
P 是函数的输入之一,用的时候没有赋值
{:{49}:}强!好眼力 ??? Undefined function or variable 'P'
Ref:
2.常见的程序出错问题整理 http://forum.vibunion.com/thread-46001-1-1.html
From http://home.vibunion.com/blog-63979-18250.html 321forever 发表于 2013-10-30 14:57 static/image/common/back.gif
P 是函数的输入之一,用的时候没有赋值
赋值后,还是不行,求指导。function lambda_1=largest_lyapunov_exponent(data,N,m,tau,P)
%the function is used to calcultate largest lyapunov exponent with the
%mended algorithm,which put forward by lv jing hu.
%data:the time series
%N:the length of data
%m:enbedding dimention
%tau:time delay
%P:the mean period of the time series,calculated with FFT
%lambda_1:return the largest lyapunov exponent
%skyhawk
data=load('b.txt');
N=length(data);
m=2;
tau=6;
p=6;
delt_t=1;
Y=reconstitution(data,N,m,tau );%reconstitute state space
M=N-(m-1)*tau;%M is the number of embedded points in m-dimensional space
for j=1:M
d_max=1e+100;
for jj=1:M %寻找相空间中每个点的最近距离点,并记下
d_s=0; %该点下标
if abs(j-jj)>P %限制短暂分离
for i=1:m
d_s=d_s+(Y(i,j)-Y(i,jj))*(Y(i,j)-Y(i,jj));
d_min=d_max;
if d_s<d_min
d_min=d_s;
idx_j=jj;
end
end
end
end
% index(j)=idx_j;
max_i=min((M-j),(M-idx_j));%计算点j的最大演化时间步长i
for k=1:max_i %计算点j与其最近邻点在i个离散步后的距离
d_j_i=0;
for kk=1:m
d_j_i=d_j_i+(Y(kk,j+k)-Y(kk,idx_j+k))*(Y(kk,j+k)-Y(kk,idx_j+k));
d(k,j)=d_j_i;
end
end
end
%对每个演化时间步长i,求所有的j的lnd(i,j)平均
=size(d);
for i=1:l_i
q=0;
y_s=0;
for j=1:l_j
if d(i,j)~=0
q=q+1;
y_s=y_s+log(d(i,j));
end
end
y(i)=y_s/(q*delt_t);
end
x=1:length(y);
pp=polyfit(x,y,1);
lambda_1=pp(1);
yp=polyval(pp,x);
plot(x,y,'-o',x,yp,'--')请帮忙看看,谢谢了。 1.求助完整格式:出错代码和出错提示
2.直觉楼主不是很清楚m-function与m-script的差异, 建议看下帮助文献 原来是小飞 发表于 2013-11-6 16:43 static/image/common/back.gif
赋值后,还是不行,求指导。请帮忙看看,谢谢了。
lz 是怎么调用的程序 ChaChing 发表于 2013-11-2 09:19 static/image/common/back.gif
Ref:
2.常见的程序出错问题整理 http://www.chinavib.com/thread-46001-1-1.html
From http://home.chi ...
It is wonderful!!{:{39}:}谢谢分享
页:
[1]