Subscript indices must either be real positive integers or logicals

1 visualización (últimos 30 días)
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

Respuestas (0)

Categorías

Más información sobre Multidimensional Arrays en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by