clc;clear all;close all
%I separated the data points of the top and the bottom of the airfoil so I
%can use interp1 separately for both
%Data points of the top part of the airfoil
x=[1 0.8518 0.7040 0.5536 0.3988 0.2454 0.0937 0.0199 0.0015 0];
y=[0 0.0355 0.0819 0.1206 0.1347 0.1200 0.0777 0.0363 0.0162 0];
%Data points of the bottom part of the airfoil
x2=[0 0.0169 0.0812 0.2054 0.3525 0.4979 0.6457 0.7974 0.9497 1];
y2=[0 -0.0197 -0.0428 -0.0645 -0.0749 -0.0701 -0.0506 -0.0249 -0.0026 0];
%Smoothing both the top and bottom part of the airfoil using
%interp1('pchip')
xx=linspace(1,0);
yy=interp1(x,y,xx,'pchip');
xx2=linspace(0,1);
yy2=interp1(x2,y2,xx2,'pchip');
%Plotting both my smoothed top and bottom data points into the same plot
figure
plot(xx,yy,'b',xx2,yy2,'b')
grid on
This is what I have come up with so far. How do I find the centroid of this airfoil

1 Comment

Programs that have "clear all" in them are almost always wrong.

Sign in to comment.

 Accepted Answer

Walter Roberson
Walter Roberson on 8 Dec 2013

0 votes

If you have the image processing toolbox, you can use the xx, yy, xx2, yy2 coordinates as inputs to poly2mask(). Then you can use regionprops() to find the centroid of the mask.

4 Comments

That's what I was thinking, though I was waiting/thinking/hoping that there was some built in function to do that, like polyarea for the area. I thought there might be polycentroid(). The IPT way requires quantization of the data into an image. I bet Roger has an analytical solution. If not, then regionprops will be reasonably accurate as long as your image matrix has high enough resolution.
Oh, there are more direct methods ;-)
Looks like Wikipedia has it. Too bad MATLAB doesn't. But it's simple enough to program https://en.wikipedia.org/wiki/Centroid#Centroid_of_polygon
I'm pretty sure that a good-enough approximation can be done much much more easily than that. But I'm feeling mean mean tonight I guess.

Sign in to comment.

More Answers (0)

Categories

Tags

No tags entered yet.

Community Treasure Hunt

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

Start Hunting!