Unable to perform assignment because the size of the left side is 1 by 1 and the size of the right side is 1 by 2

조회 수: 1 (최근 30일)
I'm trying to use the source panel method for a computaional fluid dynamics problem, but my code is giving the error stated in the title at Inorm in the embedded for loop. All of the code above "working code" is just given for context. Please help me out here.
C = 2; %Chord Length
a18 = .574; % f Plane Circle radius
TR18 = 0.18; %Thickness Ratios
epsilon18 = .0721; %Thickness parameters
k = 1.889; %Trailing edge angle parameter
theta = 0:.0001:deg2rad(360); %theta runs from 0 to 2pi in very small increments, deg2rad is a conversion
%Equations for Van de Vooren Airfoil r & theta when TR = .18
r1_18 = sqrt(((a18.*cos(theta))-a18).^2+((a18.*sin(theta))).^2);
r2_18 = sqrt(((a18.*cos(theta))-(epsilon18.*a18)).^2+(a18.*sin(theta)).^2);
theta1_18 = atan2(a18.*sin(theta),(a18.*cos(theta))-a18);
theta2_18 = atan2(a18.*sin(theta),(a18.*cos(theta))-epsilon18.*a18);
%x and z coordinates of the Van de Vooren airfoil when TR = .18
x1_18 = ((r1_18).^k)./((r2_18).^(k-1));
x2_18 = cos(k.*theta1_18).*cos((k-1).*theta2_18);
x3_18 = sin(k.*theta1_18).*sin((k-1).*theta2_18);
x18 = x1_18.*(x2_18+x3_18); %splits up the eq
z1_18 = ((r1_18).^k)./((r2_18).^(k-1));
z2_18 = sin(k.*theta1_18).*cos((k-1).*theta2_18);
z3_18 = cos(k.*theta1_18).*sin((k-1).*theta2_18);
z18 = z1_18.*(z2_18-z3_18); %splits up the eq
N = 8; % number of panels
dx = 4/N; % change in x
xp = zeros(1,N/2);
xp(1) = 0; % first xp in panel method will always be 0
xp(2) = x18(1) - dx; % 2nd xp val calc
zp = zeros(1,N+1 - N/2);
zp(1) = 0;
for i = 3:1:(N/2 + 1)
xp(i) = xp(i-1) - dx;
end
xp = [xp, flip(xp(1:N/2),2)]; % airfoil is symmetrical; flip xp variables about x-axis
% first zp will always be zero
for j = 2:(N/2 + 1)
n = xp(j);
[val1,idx] = min(abs(x18-n));
zp(j) = z18(idx);
if any(zp < 0)
idx2 = find(zp < 0);
zp(idx2) = zp(idx2)*-1;
end
end
zp = [zp,(-1).*flip(zp(1:N/2),2)]; % airfoil is symmetrical; flip zp variables about x-axis
plot(xp+1,zp)
set(gca, 'XAxisLocation', 'origin', 'YAxisLocation', 'origin');
title('Panel Method');
axis equal
zeta = zeros(N,1); % angle from Vinf to bottom of panel
eta = zeros(N,1); % angle from Vinf to outward normal of panel
conX = zeros(N,1); % X coordinates of control points
conZ = zeros(N,1); % Y coordinates of control points
s = zeros(N,1); % panel length
for i = 1:N
zeta(i) = -alpha0 + atan2((zp(i+1)-zp(i)),(xp(i+1)-xp(i)));
eta(i) = zeta(i)+pi/2;
if eta(i)>2*pi, eta(i)=eta(i)-2*pi;
elseif eta(i)<0, eta(i)=eta(i)+2*pi;
end
conX(i) = (xp(i+1)+xp(i))/2;
conZ(i) = (zp(i+1)+zp(i))/2;
s(i) = sqrt((xp(i+1)-xp(i))^2 + (zp(i+1)-zp(i))^2);
end
plot(xp+1,zp,'b',conX+1,conZ,'-rs');
set(gca, 'XAxisLocation', 'origin', 'YAxisLocation', 'origin');
axis equal;
legend('Panel Approximation','Control Points')
title('Panel Layout');
%//////////////////////////^^^working code^^^/////////
Inorm = zeros(N,N); % normal integral
Itan = zeros(N,N); % tangent integral
Vnorm = zeros(N,1); % normal velocity
jwoi = zeros(N-1,N); % j without i
for i=1:N
jwoi(:,i)=[1:i-1 i+1:N];
xi=conX(i);
zi=conZ(i);
for k = 1:N-1
j = jwoi(k,i);
xpj = xp(j); zpj = zp(j);
A(i,j) = -(xi-xpj)*cos(zeta(j))-(zi-zpj)*sin(zeta(j));
B(i,j) = (xi-xpj)^2+(zi-zpj)^2;
%C(i,j) = sin(zeta(i)-zeta(j));
D(i,j) = (zi-zpj)*cos(zeta(i))-(xi-xpj)*sin(zeta(i));
E = sqrt(B-A.^2);
sj = s(j);
Inorm(i,j) = C./2.*log((sj^2+2.*A.*sj+B)./B)+(D-A.*C)/E.*(atan2((sj+A),E)-atan2(A,E));
Itan(i,j) = (D-A.*C)./2./E.*log((sj.^2+2.*A.*sj+B)./B)-C.*(atan2((sj+A),E)-atan2(A,E));
end
Vnorm(i,1) = cos(beta(i));
end

채택된 답변

Catalytic
Catalytic 2022년 11월 20일
You cannot do this -
x=[1,2,3],
x = 1×3
1 2 3
x(1)=[5,6] %left side 1x1. right side 1x2
Unable to perform assignment because the left and right sides have a different number of elements.
  댓글 수: 1
Chase Visser
Chase Visser 2022년 11월 20일
Should've been obvious thanks! Still getting incompatable array sizes but I'll hopefully be able to figure that one out myslef.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Airfoil tools에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by