make a surface plot of a wing given the root and tip coordinates in matlab

To make a surface plot of a wing given the root and tip coordinates in MATLAB, you need to do the following:

  1. Define the root and tip coordinates as arrays of x, y, and z values.
  2. Create a meshgrid of x and y values using the root and tip coordinates.
  3. Use a function, such as interp2 or TriScatteredInterp, to interpolate the z values of the wing surface from the root and tip coordinates.
  4. Use the surf function to plot the wing surface.

Here is sample code that shows how to make a surface plot of a wing using the functions interp2 and surf:

main.m
% Define the root and tip coordinates of the wing
root = [0,0,0];
tip = [1,0,0.2];

% Create a meshgrid of x and y values
x = linspace(root(1),tip(1),100);
y = linspace(root(2),tip(2),100);
[X,Y] = meshgrid(x,y);

% Interpolate the z values of the wing surface
Z = interp2([root(1),tip(1)],[root(2),tip(2)],[root(3),tip(3)],X,Y);

% Plot the wing surface
surf(X,Y,Z);
368 chars
15 lines

Alternatively, you can use the TriScatteredInterp function to interpolate the z values from a set of scattered data points on the wing surface:

main.m
% Define the root and tip coordinates of the wing
root = [0,0,0];
tip = [1,0,0.2];

% Generate a set of scattered data points on the wing surface
n = 1000;
x = rand(n,1)*(tip(1)-root(1)) + root(1);
y = rand(n,1)*(tip(2)-root(2)) + root(2);
z = rand(n,1)*(tip(3)-root(3)) + root(3);

% Create a TriScatteredInterp object from the scattered data points
F = TriScatteredInterp(x,y,z);

% Create a meshgrid of x and y values
x = linspace(root(1),tip(1),100);
y = linspace(root(2),tip(2),100);
[X,Y] = meshgrid(x,y);

% Interpolate the z values of the wing surface from the TriScatteredInterp object
Z = F(X,Y);

% Plot the wing surface
surf(X,Y,Z);
645 chars
24 lines

related categories

gistlibby LogSnag