大神求救有关matlab 递推公式!function result=pintaun(theta,alpha)n_stop=fun_nstop(alpha);pi(1)=0;pi(2)=1;for n=3:n_stoppi(n)=(2*n-1)*cos(theta)*pi(n-1)/(n-1)-n*p1(n-2)/(n-1);tau(n)=n*cos(theta)*pi(n)-(n+1)*pi(n-1);end;pi(n)=pi(n-1);tau(n)=ta

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/01 00:23:36

大神求救有关matlab 递推公式!function result=pintaun(theta,alpha)n_stop=fun_nstop(alpha);pi(1)=0;pi(2)=1;for n=3:n_stoppi(n)=(2*n-1)*cos(theta)*pi(n-1)/(n-1)-n*p1(n-2)/(n-1);tau(n)=n*cos(theta)*pi(n)-(n+1)*pi(n-1);end;pi(n)=pi(n-1);tau(n)=ta
大神求救有关matlab 递推公式!
function result=pintaun(theta,alpha)
n_stop=fun_nstop(alpha);
pi(1)=0;
pi(2)=1;
for n=3:n_stop
pi(n)=(2*n-1)*cos(theta)*pi(n-1)/(n-1)-n*p1(n-2)/(n-1);
tau(n)=n*cos(theta)*pi(n)-(n+1)*pi(n-1);
end;
pi(n)=pi(n-1);
tau(n)=tau(n-1);
result=[pi(n),tau(n)];
我是菜鸟,这个程序为什么是错的啊?
(n_stop=fun_nstop(alpha);这个有子程序且无错)
matlab提示错误:
>> result=pintaun(0.5,5)?Undefined function or method 'p1' for input arguments of type 'double'.
Error in ==> pintaun at 6
pi(n)=(2*n-1)*cos(theta)*pi(n-1)/(n-1)-n*p1(n-2)/(n-1);

大神求救有关matlab 递推公式!function result=pintaun(theta,alpha)n_stop=fun_nstop(alpha);pi(1)=0;pi(2)=1;for n=3:n_stoppi(n)=(2*n-1)*cos(theta)*pi(n-1)/(n-1)-n*p1(n-2)/(n-1);tau(n)=n*cos(theta)*pi(n)-(n+1)*pi(n-1);end;pi(n)=pi(n-1);tau(n)=ta
出错的地方电脑都告诉你了,就是这个
pi(n)=(2*n-1)*cos(theta)*pi(n-1)/(n-1)-n*p1(n-2)/(n-1);
这里面最后一项里的p1没有定义,要不就是你把pi输成了p1.