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!