Matrix dimensions with sin(atan)

8 次查看(过去 30 天)
I think it is that the sin and atan functions are vectors that arent the same size. And also a plot window always pops up in the begining when i run my code.
here is the error:
Matrix dimensions must agree.
Error in HW16NACA (line 71)
UpperXF = xC-YThick.*sin(ThetaF);
clc;
clear;
close all;
format compact;
axis equal;
Choice = input('Pick an option by entering the number associated with it.\n1)Example NACA Airfoil\n2)Enter 4-digit NACA number\n3)Random NACA\n-->','s');
while length(Choice)~=1 | isnan(Choice) | str2double(Choice)~=1:3
Choice = input('Error: Not an option.\n\nPlease pick 1, 2, or 3.\n-->','s');
end
Choice = str2double(Choice);
TrailE = input('\nClosed Trailing Edge?\n1)Yes\n2)No\n-->','s');
while length(TrailE)~=1 | isnan(TrailE) | str2double(TrailE)~=1:2
TrailE = input('\nPlease only enter 1 or 2.\n-->','s');
end
if TrailE == 1
a4 = -0.1036;
else
a4 = -0.1015;
end
if Choice == 1
NNumb = int2str(2412);
end
M = str2double(NNumb(1))/100;
P = str2double(NNumb(2))/10;
xx = str2double(NNumb(end-1:end))/100;
a0 = 0.2969;
a1 = -0.126;
a2 = -0.3516;
a3 = -0.2843;
x=linspace(0,P);
CamberFY = (M/P^2)*(2*P.*x-x.^2);
GradientF = (2*M/P^2).*(P-x);
plot(x,CamberFY,'-g');
hold on;
x=linspace(P,1);
CamberBY = (M/(1-P)^2)*(1-2*P+2*P.*x-x.^2);
GradientB = (2*M/((1-P)^2)).*(P-x);
plot(x,CamberBY,'-g');
hold on;
x=0:1;
YThick = (xx/0.2)*(a0.*x.^0.5+a1.*x+a2.*x.^2+a3.*x.^3+a4.*x.^4);
pi = 3.1415926535;
B=linspace(0,pi);
xC = (1-cos(B))/2;
ThetaF = atan(GradientF);
ThetaB = atan(GradientB);
UpperXF = xC-YThick.*sin(ThetaF);
UpperXB = xC-YThick.*sin(ThetaB);
LowerXF = xC+YThick.*sin(ThetaF);
LowerXB = xC+YThick.*sin(ThetaB);
UpperYF = CamberFY+YThick.*cos(ThetaF);
UpperYB = CamberBY+YThick.*cos(ThetaB);
LowerYF = CamberFY-YThick.*cos(ThetaF);
LowerYB = CamberBY-YThick.*cos(ThetaB);
plot(UpperXF,UpperYF,':r');
plot(UpperXB,UpperYB,':g');
plot(LowerXF,LowerYF,'--r');
plot(LowerXB,LowerYB,'--g');
  2 个评论
Geoff Hayes
Geoff Hayes 2019-2-18
Brandon - the problem with
UpperXF = xC-YThick.*sin(ThetaF);
is that YThick is a 1x2 matrix and ThetaF (and so sin(ThetaF)) is a 1x100 matrix and so this multiplication will fail. Do these dimensions make sense for what the code is trying to do?
Brandon Ormsby
Brandon Ormsby 2019-2-18
okay i got no error this time and a graph by replacing line 80 with x=linspace(0,1); so 1x100=1x100
thank you!

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by