MATLAB出现?Subscript indices must either be real positive integers or logicalsclear all %a .mRh=input('请输入环半径,Rh=');I0=input('请输入环电流,I0=');mu0=4*pi*1e-7;C0=mu0/(4*pi)*10; %归常数Nh=20; %电流环分段数x=linspace(-3,3,N

来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/25 22:25:52
MATLAB出现?Subscriptindicesmusteitherberealpositiveintegersorlogicalsclearall%a.mRh=input(''请输入环半径,Rh=''

MATLAB出现?Subscript indices must either be real positive integers or logicalsclear all %a .mRh=input('请输入环半径,Rh=');I0=input('请输入环电流,I0=');mu0=4*pi*1e-7;C0=mu0/(4*pi)*10; %归常数Nh=20; %电流环分段数x=linspace(-3,3,N
MATLAB出现?Subscript indices must either be real positive integers or logicals
clear all %a .m
Rh=input('请输入环半径,Rh=');
I0=input('请输入环电流,I0=');
mu0=4*pi*1e-7;
C0=mu0/(4*pi)*10; %归常数
Nh=20; %电流环分段数
x=linspace(-3,3,Nh);y=x; %确定观测点的范围
theta0=linspace(0,2*pi,Nh+1); %环的圆周角分段
thetal=theta0(1,Nh);
y1=Rh*cos(thetal); %环各段矢量的起点坐标y1,z1
z1=Rh*sin(thetal);
theta2=theta0(2:Nh+1);
y2=Rh*cos(theta2); %环各段矢量的终点坐标y2,z2
z2=Rh*sin(theta2);
xc=0;yc=(y2+y1)/2;zc=(z2+z1)/2; %计算环各段矢量中的点的坐标分量
dlx=0;dly=y2-y1;dlz=z2-z1; %计算环各段矢量d1的3个分量,x1=x2=0
NGx=Nh;NGy=NGx; %确定网格线数
for i=1:NGx
rx=x(j)-xc,ry=y(i)-yc,rz=0-zc; %计算矢径r的3个长度分量,P点z=0
r3=sqrt(rx.^2+ry.^2+rz.^2).^3; %计算r^3
dlXr_x=dly.*rz-dlz.*ry; %计算叉乘积dl×r的x和y分量,z分量为0
dlXr_y=dlz.*rx-dlx.*rz;
Bx(i,j)=sum(C0*dlXr_x./r3); %把环各段产生的磁场分量累加
By(i,j)=sum(C0*dlXr_y./r3);
B=(Bx.^2+By.^2).^0.5; %计算B的大小
end
subplot(1,2,1),quiver(x,y,Bx,By); %用quiver画磁场矢量图
xlabel('x'),ylabel('y')
axis([-3,3,-3,3])
subplot(1,2,2)
mesh(x,y,B); %画磁场大小分布图
xlabel('x'),ylabel('y'),zlabel('v')
————————————————————————————————————————————
Subscript indices must either be real positive integers or logicals.
Error in ==> dianci at 19
rx=x(j)-xc,ry=y(i)-yc,rz=0-zc; %计算矢径r的3个长度分量,P点z=0
请问错在了那里?在十九行以下还出现什么错误了吗?

MATLAB出现?Subscript indices must either be real positive integers or logicalsclear all %a .mRh=input('请输入环半径,Rh=');I0=input('请输入环电流,I0=');mu0=4*pi*1e-7;C0=mu0/(4*pi)*10; %归常数Nh=20; %电流环分段数x=linspace(-3,3,N
这个错误是说:
角标不能是正整数或逻辑变量
由于你的循环变量是i
而你下面的循环又用j
rx=x(j)-xc
这句应当是
rx=x(i)-xc %j改成i

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. 用matlab图像配准中出现Subscript indices must either be real positive integers or logicals是什么题I=imread('lily.jpg');lily=rgb2gray(I);M=imread('flowers.jpg');flowers=rgb2gray(M);%选择图像的配准区域imshow(lily)figure,imshow(flowe lingo中出现问题:subscript out of range on attribute, matlab 出现Subscript indices must either be real positive integers or logicals样的错误这是2007年B题的程序:st=3748;en=2160;y=1;za=[];for i=1:k(st)for j=1:k(en)if Z(en,j)==Z(st,i)df=round(Z(en,j));aa=find(L{df,4}==st);%AAbb= find(L{df,4} 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 lingo中出现问题:subscript out of range on attribute,请尽量说的详细点 matlab仿真老是出现错误,请问怎么改?clear;clc;deta=2;w=2.5;theta=0;a=linspace(-10,10,25);b=linspace(-1.0,1.0,25);[x,y]=meshgrid(a,b);s(x,y)=exp(-0.5*((x/deta)^2+(y/deta)^2)).*sin(w*(x*cos(theta)+y*sin(theta)));plot3(x,y,s(x,y)); Subscript 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问题 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出现?Subscript indices must either be real positive integers or logicalsclear all %a .mRh=input('请输入环半径,Rh=');I0=input('请输入环电流,I0=');mu0=4*pi*1e-7;C0=mu0/(4*pi)*10; %归常数Nh=20; %电流环分段数x=linspace(-3,3,N matlab出现? Subscript indices must either be real positive integers or logicals.t=-10:0.01:10; k=-2;x(t)=exp(k*t-1);t1=-t-2;t2=t/5+2;t3=3t+2;x(t1)=exp(k*t1-1);x(t2)=exp(k*t2-1);x(t3)=5*exp(k*t3-1) MATLAB里出现Subscript indices must either be real positive integers or logicals.% CMAC逼近sin(t)函数% 未进行Hash Coding杂凑% 作者:nuaazdh %时间:2012年2月23日16:53:28 clear all; close all; clc; t=[0:2*pi/360:2*pi];% 自变量t y 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 函数自变量不能从零开始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 :Subscript indices must either be real positive integers or logicalsn(1)=1;n(2)=2;n(3)=3;n(4)=4;n(5)=1;h(1)=0.02;h(2)=0.03;h(3)=0.04;for i=1:3;sita(1)=1; sita(i+1)=asin(sin(sita(i))*n(i)/n(i+1));cos(sita(i))=(1-sin(sita(i))^2)^0.5;f=1.6e10;n matlab 省略号 出现错误