필터 지우기
필터 지우기

Why do i get error "array have incompatible sizes for this operation error"

조회 수: 1 (최근 30일)
Özgür Alaydin
Özgür Alaydin 2023년 2월 23일
편집: Torsten 2023년 2월 23일
Dear all
I have problem with integral. I did not figure out what is wrong.
Please let me know the mistake.
Vb1=0.228;
Rx1=4E-9;
Ry1=4E-9;
Rx2=4E-9;
Ry2=4E-9;
x1=-6E-9;
y1=-6E-9;
x2=6E-9;
y2=6E-9;
w=1E+12; T=2*pi/w;
alfa=1E-9;
for i=1:numel(x)
for j =1:numel(y)
fx = @(t) x(i) + alfa*sin(w.*t);
idx1 =@(t) ((fx(t)-x1)/Rx1).^2 + ((y(j)-y1)/Ry1).^2 < 1;
idx2 =@(t) ((fx(t)-x2)/Rx2).^2 + ((y(j)-y2)/Ry2).^2 < 1;
Vb =@(t) (X<0).*(1-idx1(t))*Vb1 + (X>0).*(1-idx2(t))*Vb1;
V0(i,j) = (1/T).*integral(Vb,0,T);
end
end
Unrecognized function or variable 'x'.
  댓글 수: 3
Özgür Alaydin
Özgür Alaydin 2023년 2월 23일
I saw the mistake, thanks for help.
[X,Y]=meshgrid(x,y);
I wrote big X time dependente and problem solved.
Torsten
Torsten 2023년 2월 23일
편집: Torsten 2023년 2월 23일
For clarity, better use
idx1 =@(t) (((fx(t)-x1)/Rx1).^2 + ((y(j)-y1)/Ry1).^2) < 1;
idx2 =@(t) (((fx(t)-x2)/Rx2).^2 + ((y(j)-y2)/Ry2).^2) < 1;
instead of
idx1 =@(t) ((fx(t)-x1)/Rx1).^2 + ((y(j)-y1)/Ry1).^2 < 1;
idx2 =@(t) ((fx(t)-x2)/Rx2).^2 + ((y(j)-y2)/Ry2).^2 < 1;

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by