当前位置:编程学习 > Matlab >>

关于matlab的程序问题,为什么会出现‘Subscript indices must either be real positive integers or logi

程序如下: clc; clear all; k1=20; k2=1; q=0.1; %噪声强度 Ap=0.3; %信号幅值 f=0.1/(2*pi); %信号频率 L=0.1; p=i*2*pi*f; h=k1*L/q; b=k1^2/(2*p*q); r1=sqrt(1+4*p*q/k1^2); r2=sqrt(1+4*p*q/k2^2); v=k2/k1; %delt lang=1-exp(h); %朗姆达 u=1-exp(h*r1); a1=sqrt(1-u)-1/(sqrt(1-lang)); a2=sqrt(1-u)-sqrt(1-lang); S=q/(2*p*b*v^2)*(2+2*h*v+h^2*v^2-(h^2+2*h+2*lang))*v^3/(1-lang*v); %方差 m=0; %均值 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%上面一段是各个参数的赋值 A0=4*q*b*lang*u*(1-4*v)/(1-lang*v); A1=-8*q*b*(1-v)*((1-lang)*a1^2+a2^2)*r1; A2=2*q*(2*lang*u*(2-v)-4*v*u+v*lang*(2-u)*r1)/(1-lang*v); A3=-4*q*r1*((2-v)*a2^2+v*lang(2+(2-u)*r2))/(v^2*(1-lang*v)*(1+r2)); A4=-4*q*r1*a1^2*(2-3*v)*(1-lang)/(v^2*(1-lang*v)*(1+r2)); A5=2*q*u*((2-v)*lang+2*v(2-lang)*r2+2*v(1-lang))/(v^2*(1-lang*v)*(1+r2)); A6=q*r1*(2-u)*(v*lang*(1+r2)-6+2*v-2*r2)/(b*v^2*(1-lang*v)*(1+r2)); A7=2*q*u(1+v*(2-lang)-2*v^2*lang)*r2/(b*v^2*(1-lang*v)*(1+r2)); A8=2*q*u(3+4*lang-2*v^2*lang-v(2+3*lang))/(b*v^2*(1-lang*v)*(1+r2)); A9=4*q*u/(b^2*v^3*(1+r2)); B=p^2*(1+r2)^2*((2-u)*r2-u(1-v+v*r2)); A=[A0,A1,A2,A3,A4,A5,A6,A7,A8,A9]; K=S^2/p+sum(A)/B; SNR_out=Ap^2*(S+m-p*K)^2/(q*pi*real(K)) %%点击程序运行到A3那里出现‘Subscript indices must either be real positive integers or logicals’,A3如果用笔算也能算出,为什么matlab会出现这样的问题,之后的A5,A7,A8,A9都是同样的问题,求高手帮助!!!!!
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,