? Subscript indices must either be real positive integers or logicals. 什么错误啊?n=[1:15];x=zeros(1,15);x=rand(1,10);z=zeros(1,15);y=[x,0,0,0,0,0];forj=3:1:12z(j)=y(j-2)endsubplot(2,1,1);stem(n,y);subplot(2,1,2);stem(n,z)

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/15 19:29:14

? Subscript indices must either be real positive integers or logicals. 什么错误啊?n=[1:15];x=zeros(1,15);x=rand(1,10);z=zeros(1,15);y=[x,0,0,0,0,0];forj=3:1:12z(j)=y(j-2)endsubplot(2,1,1);stem(n,y);subplot(2,1,2);stem(n,z)
? Subscript indices must either be real positive integers or logicals. 什么错误啊?
n=[1:15];x=zeros(1,15);x=rand(1,10);z=zeros(1,15);y=[x,0,0,0,0,0];
forj=3:1:12
z(j)=y(j-2)
end
subplot(2,1,1);stem(n,y);subplot(2,1,2);stem(n,z)

? Subscript indices must either be real positive integers or logicals. 什么错误啊?n=[1:15];x=zeros(1,15);x=rand(1,10);z=zeros(1,15);y=[x,0,0,0,0,0];forj=3:1:12z(j)=y(j-2)endsubplot(2,1,1);stem(n,y);subplot(2,1,2);stem(n,z)
Subscript indices must either be real positive integers or logicals
下标索引必须是正整数类型或者逻辑类型
出错原因:在访问矩阵(包括向量、二维矩阵、多维数组,下同)的过程中,下标索引要么从 0 开始,要么出现了负数.注:matlab 的语法规定矩阵的索引从 1 开始,这与 C 等编程语言的习惯不一样.
解决办法:自己调试一下程序,把下标为 0 或者负数的地方修正.
另,你的程序我运行了,没有错误.能得到结果.
我的运行环境是Matlab 7.5.0(R2007b),WindowsXP SP3

Subscript indices must either be real posit... Subscript indices must either be real positive integers or logicals. Subscript indices must either be real positive integers or logicals. matlab为什么出现 Subscript indices must either be real positive integers or logicals.为什么出现>> A=[2 -3 -2;-1 2 1;4 -7 -6];>> C=det(A)Subscript indices must either be real positive integers or logicals. >> p=[1 0 3 12 7]p = 1 0 3 12 7>> roots(p)? Subscript indices must either be real positive integers or logicals.>> matlab中for语句画图,Subscript indices must either be real positive integers or logicals.for ii=0.1:1x=0:100y(ii)=(L-ii*hg)/(ii*hg)*x-G*b/hg;plot(x,y(ii))hold onend出现Subscript indices must either be real positive integers or logicals.这个 matlab运行 >> x=1:0.01:200; >> a=max(x);出现Subscript indices must either be real positive integers orlogicals.程序明显没有问题,在2012b上可以运行,系统版本2010b MATLAB function numpositivi=es1(flussi)nf=numel(flussi); numpositivi=0; for i=1:nf if flussi(i)>0 � numpositivi=numpositivi+1end end检验> V=[1 -2 4 -2 -8 -5 6 8 10]V =1 -2 4 -2 -8 -5 6 8 10>> es1(V)Subscript indices must either be real posit matlab num=[4];den=[1 2 1]; margin(num,den),grid; w=0.1:1000; [mag,phase,w]=bode(num,den);mag(1)mag(1.5)输出:mag(1)=3.9996但是mag(1.5)出了问题,如下:Subscript indices must either be real positive integers or logicals.只要mag( matlab slice 函数,为什么例子也出错?matlab Help中关于slice作图函数,给出了一个例子然后我copy到命令行里,或者.m中试了试,结果就出来了这么个警告:Subscript indices must either be real positive integers or log matlab 运行下面的程序出现一些错误,请帮忙看看错误在哪里,谢谢.程序syms x n mn=0;m=1377*10^6;x=0.1:0.01:6;f(x)=(x.*19.1*300*300*pi.*(1-(sin(2*pi.*x))/(2*pi.*x))-n)/((3*x-1.25)*360);plot(x,f(x))运行出错? Subscript indices m MATLAB求解多项式的问题从书上直接抄的两行p=[1 -2 0 25 116]r=roots(p)运行之后居然报错subscript indices must either be real positive integers or logicals.我的版本是7.8.0(R2009a),不知道和这个有没有关系 matlab 函数自变量不能从零开始load Txfdwx(x,y,t) = Txf(i-1,j-1,t);%改变时间值可以画出不同时间的等温线zhb=contour(dwx(50));clabel(zhb)由于i =1:19,j=1:19之后运行说Subscript indices must either be real positive intege 关于Matlab的问题t=1:0.5:50;if t>=0&t10&t20&t30v(t)=1520*e^(-0.2*(t-30));else v(t)=0;endplot(t,v(t))Subscript indices must either be real positive integers or logicals.我想问问这个到底发生什么问题了,需要怎么改? matlab问题 sin[a(t-t0)] -------------- a(t-t0) 要求是做图a=2;t0=1;t=1:0.1:10;y=sin(a*(t-t0))/a(t-t0);老是出现 Subscript indices must either be real positive integers or logicals.怎么回事啊虚线部分是除的意思 这段matlab代码错在哪里了出现这个错误:Subscript indices must either be real positive integers or logicals.D是一个9*9邻接矩阵,这段代码想把邻接矩阵的边保存到一个2列矩阵L中,L的每一行存储一条边的两 matlab这个式子哪里出问题了?v=2*0.89*0.6*l((h-0.6)/(2*0.6).*sqrt(1-((h-0.6)/0.6).^2)+0.5*asin((h-0.6)/0.6)+pi/4);l是常数 赋值过了 h是列向量错误说:Subscript indices must either be real positive integers or logicals. 之后的运行又出现:Subscript indices must either be real positive integers or logicals[f,r]=meshgrid(500:10:1500,0.015:0.00020:0.035);a1=0.01;%孔半径ua=1;%空气柱振速w=2*pi.*f;c=340;%声速k=w./c;%a=0;%位置点的x坐标b=0.015;%位