Subscript indices must either be real positive integers or logicals
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello everyone!
I am getting indices error in this for loop when computing Vx(m,n), although they are real positive integers, what could be the problem?
nGridX = 100;
nGridY = 100;
xVals = [-0.5; 1.5];
yVals = [-0.5; 0.5];
%Streamlines parameters
stepsize = 0.01;
maxVert = nGridX * nGridY * 10;
slPct = 30;
Ysl = linspace (yVals(1), yVals(2),floor((slPct/100)*nGridY))';
%Generate the grid points
Xgrid = linspace(xVals(1),xVals(2),nGridX)';
Ygrid = linspace(yVals(1),yVals(2),nGridY)';
[XX,YY] = meshgrid(Xgrid,Ygrid);
%Initizalize
Vx = zeros(nGridX,nGridY);
Vy = zeros(nGridX,nGridY);
for m = 1:nGridX
for n = 1:nGridY
XP = XX(m,n);
YP = YY(m,n);
[Mx, My] = Streamline_function1(XP, YP, x, y, phi,s);
[in, on] = inpolygon (XP, YP, x, y);
if (in == 1 || on == 1)
Vx(m,n) = 0;
Vy(m,n) = 0;
else
Vx(m,n) = V_inf*cosd(AoA_deg) + sum(lambda.*Mx./(2*pi));
Vy(m,n) = V_inf*sind(AoA_deg) + sum(lambda.*My./(2*pi));
end
end
end
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!