Subscript indices must either be real positive integers or logicals

1 回表示 (過去 30 日間)
charbel chemaly
charbel chemaly 2020 年 11 月 27 日
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 件)

カテゴリ

Help Center および File ExchangeMultidimensional Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by