New to matlab problem plotting

Hello guys! I'm new to matlab and i have to make a 3D plot. I have managed to do that for a 2D graph (like a cross-sectional view) and tried searching for hours on how can i make it a 3D shape but without any luck. I have attached the code i wrote for the 2D version as well as pics of how it looks like and how it's supposed to look like. I hope you can give me some insight on how to do it.
t=linspace(0,2*pi);
r=1.1;
xc=-0.1;
yc=0.05;
x=r*cos(t)+xc;
y=r*sin(t)+yc;
plot(x,y)
axis equal
zeta=x+i*y;
z=zeta+1./zeta; hold on; plot(-1,0,'rs',1,0,'gd'); plot (real(z),imag(z))

 Accepted Answer

Star Strider
Star Strider on 7 Jan 2021
See: how to convert 2D graph to 3D? for one approach.
The second image looks as though it was copied from my Answer in that post!

7 Comments

Hello, I'm sorry for using your picture but it was exactly what i was looking for in order to explain what i am trying to do. In terms of the end result, your post is exactly what i needed, however i have to use the joukowsky problem in order to make the airfoil shape. This is the exercise: "Using the Joukowsky transform draw a "wing" by adding the third dimension to the curve. The wing should be "horizontal" (the profile is defined in the Oxz axis) and span on the y axis.". Once again i am a complete beginner with matlab and from what i understood from searching online, the joukowsky transformation is a way to make an airfoil shape from a circle. As i said, i hope i didn't upset you by using your post and i hope you can make me understand this a little bit better.
See if this does what you want:
t=linspace(0,2*pi);
r=1.1;
xc=-0.1;
yc=0.05;
x=r*cos(t)+xc;
y=r*sin(t)+yc;
figure
plot(x,y)
axis equal
zeta=x+i*y;
z=zeta+1./zeta; hold on; plot(-1,0,'rs',1,0,'gd'); plot (real(z),imag(z))
figure
hs = surf([real(z);real(z)], [imag(z);imag(z)], [0; 10]*ones(size(z)), 'EdgeColor','none');
rotate(hs, [1 0 0], 90)
axis equal
set(gca, 'Color','none', 'GridAlpha',0, 'XColor','none', 'YColor','none', 'ZColor','none') % Experiment With These Options
producing:
Aerospace engineering is not an area of my expertise. (The closest I can gget to it is being an Instrument-Rated Private Pilot.) I have no idea of what the Joukowsky transform is or what it does, so I cannot help you with that part.
Thank you very much for your help, it's exactly what i needed. I understood what you did except in 2 places. Would you mind trying to explain in the simplest way you can what these two parts do?
[0; 10]*ones(size(z)) %1
and
rotate(hs, [1 0 0], 90) %2
My pleasure!
(I was away for an hour attendng an on-line Medical Grand Rounds on artificial intelligence in disease characterisation. Definitely interesting, and relevant to the MATLAB Deep Learning Toolbox functions that I need to become more experienced with.)
First:
[0; 10]*ones(size(z)) %1
creates a vector that has a value of 0 in the first row and a value of 10 in the second row, in order to create the necessary depth (here, wing length) to plot the surface object. Vary the values in the [0; 10] vector to see how it works. Using that same idea, the surf call could be re-coded as:
hs = surf([1;1]*real(z), [1;1]*imag(z), [0; 10]*ones(size(z)), 'EdgeColor','none');
with the same result.
Second:
rotate(hs, [1 0 0], 90) %2
uses the rotate function to rotate the wing from its original vertical orientation to a horizontal orientation. Again, vary the last 2 arguments to get different results and to see how it works.
.
If my Answer helped you solve your problem, please Accept it!
.
Ok, got it. Once more, thank you for clearing this up and i hope you have a great day!
As always, my pleasure!
You, too!

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!