how to convert 2D graph to 3D?

76 次查看(过去 30 天)
I writed a code that can give us a 2D wing airfoil with specific number points and coordinations of each one, is there any example or documentations about making my airfoil 3D by only extending it or by controlling the projection of it
  3 个评论
oussama souadka
oussama souadka 2016-11-20
yes exactly, and if the is any possibility to change the projection. like if i create 2 different airfoils one in Z=0 and the other Z=x for example can i connect them ??
KSSV
KSSV 2016-11-20
Yes can be connected...how you want it?

请先登录,再进行评论。

采纳的回答

Star Strider
Star Strider 2016-11-20
编辑:Star Strider 2016-11-20
I don’t have your wing section or your code creating it, so I created something that resembles it (the (2xN) ‘y’ matrix has the upper wing profile in the first row and the lower wing profile in the second row), then did the plot:
x = linspace(0, 1, 100); % Create Data (Independent Variable)
y = [x.*exp(-8.0*x); -x.*exp(-8.0*x)]; % Create Data (Dependent Variable Matrix)
figure(1)
plot(x, y) % 2-D Wing Section
grid
figure(2)
surf([x; x], [y(1,:); y(1,:)], [zeros(size(x)); ones(size(x))]) % Upper Half Of 3-D Wing Section
hold on
surf([x; x], [y(2,:); y(2,:)], [zeros(size(x)); ones(size(x))]) % Lower Half Of 3-D Wing Section
hold off
grid on
The Plot
You will have to adapt this to your own code, but it should not be difficult. You simply have to put your wing profiles in the rows of the ‘y’ matrix, and use the ‘x’ you used to plot your 2-D plot as the independent variable.
(I admit to a bit of cheating. I looked at the way the cylinder function creates its cylinder, then adapted that idea to plot your wing section.)
EDIT
I found some code for a NACA airfoil, so adapted my earlier code to it. The airfoil is plotted horizontally in figure(2). Note the rotate calls after the plot.
Airfoil Code (Archive)
c=1; %chord length
s=num2str(2412);
NACA=s; %4 digits
d1=str2double(s(1)); % pulls the first digit out of the scalar
d2=str2double(s(2));% pulls the second digit out of the scalar
d34=str2double(s(3:4)); % pulls the third and fourth digit out of the scalar
m=d1/100;
p=d2/10;
t=d34/100;
x=linspace(0, c, 250);
yt =5*t*c*(.2969*(sqrt(x/c))+-.1260*(x/c)+-.3516*(x/c).^2+.2843*(x/c).^3+-.1015*(x/c).^4);
for k = 1:length(x)
if x(k) <= p*c
yc(k)=m*(x(k)/p^2)*(2*p-(x(k)/c));
dx(k)=(2*m)/p^2*(p-(x(k)/c));
elseif x(k) > p*c
yc(k)=m*((c-x(k))/(1-p)^2)*(1+(x(k)/c)-(2*p));
dx(k)=((2*m)/(1-p)^2)*(p-(x(k)/c));
end
%upper and lower limits of the airfoil (xu,yu) ; (xl,yl)
theta=atan(dx(k));
xu(k)=x(k)-yt(k)*sin(theta);
yu(k)=yc(k)+yt(k)*cos(theta);
xl(k)=x(k)+yt(k)*sin(theta);
yl(k)=yc(k)-yt(k)*cos(theta);
end
%plot of airfoil
plot(xu,yu)
hold on
plot(xl,yl,'r')
plot(x,yc,'g')
axis equal
grid
figure(2)
hu = mesh([xu; xu], [yu; yu], [zeros(size(xu)); ones(size(xu))]); % Upper Half Of 3-D Wing Section
hold on
hl = mesh([xl; xl], [yl; yl], [zeros(size(xl)); ones(size(xl))]); % Lower Half Of 3-D Wing Section
hold off
grid on
axis([0 1 -0.4 0.4 0 1])
rotate(hu,[1 0 0], 90)
rotate(hl,[1 0 0], 90)
title('NACA 2412 Airfoil')
The Second Plot
  8 个评论
Justin Chan
Justin Chan 2019-3-21
How would you find the volume within the surf plot?
Anh Phan Viet
Anh Phan Viet 2020-3-16
Excuse me, how can I fill your first 3D image with colour inside?

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Airfoil tools 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by