Subscript indices must either be real positive integers or logicals
1 view (last 30 days)
Show older comments
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 Comments
Answers (0)
See Also
Categories
Find more on Multidimensional Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!