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!