Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.
2 次查看(过去 30 天)
显示 更早的评论
When i try to run the code i am getting an error "Unable to perform assignment because the indices on the left side are not compatible with the size of the right side".
Whats wrong? I did not understand.
Nx=50;
Ny=50;
Mx=20e-9;
My=20e-9;
x=linspace(-Mx/2,Mx/2,Nx);
y=linspace(-My/2,My/2,Ny);
[X,Y]=meshgrid(x,y);
Vb1=0.228;
Rx1=5e-9;
Ry1=5e-9;
alfa=0e-9; w=1E+12; T=2*pi/w;
for i=numel(x)
fx =@(t) x(i) + alfa.*sin(w.*t);
idx=@(t) (fx(t)./Rx1).^2 + (Y./Ry1).^2 < 1;
Vb = @(t) idx(t).*0 + (1-idx(t)).*Vb1;
V0(i) = (1/T).*integral(Vb,0,T,'ArrayValued',true);
end
0 个评论
回答(1 个)
Torsten
2022-3-3
Nx=50;
Ny=50;
Mx=20e-9;
My=20e-9;
x=linspace(-Mx/2,Mx/2,Nx);
y=linspace(-My/2,My/2,Ny);
Vb1=0.228;
Rx1=5e-9;
Ry1=5e-9;
alfa=0e-9; w=1E+12; T=2*pi/w;
T = 1.0;
for i=numel(x)
for j = 1:numel(y)
fx =@(t) x(i) + alfa.*sin(w.*t);
idx=@(t) (fx(t)./Rx1).^2 + (y(j)/Ry1).^2 < 1;
Vb = @(t) idx(t).*0 + (1-idx(t)).*Vb1;
V0(i,j) = (1/T).*integral(Vb,0,T,'ArrayValued',true);
end
end
5 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!