Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Matlab - importing data from excel & interpolating

  1. Nov 13, 2008 #1
    I have data that I'm using for a wind turbine project. The project requires that I retrieve data from an excel sheet that was supplied of experimentally tested values for lift and drag. These values for lift and drag are based on a value alpha (an angle, but irrelevant to the coding question).

    Right now, I have used Excel's line of best fit approximation (using a 6th degree polynomial) along with different if statements to get the values, but I've found that there can be up to 30% error in some calculations. Instead, I'd like to import the data to excel and use Matlab's interpolate function to find these values.

    The only problem is... I have no clue how to go about importing the data to excel or how to use the interpolate function. My Matlab experience is literally non-existent. I have minor experience in Java but that's it.

    What's the easiest way to import the data from excel, and what functions can I use to interpolate the data? Thanks!

    Here's the code I'm trying to replace:
    Code (Text):

                %FINDING CL
                if(alpha>0 && alpha <= 8)
                    Cl = -0.0001*alpha^5 + 0.0016*alpha^4 - 0.0093*alpha^3 + 0.0219*alpha^2 + 0.0928*alpha + 0.0006;
                elseif(alpha > 8 && alpha <= 27)
                    Cl = -.00001*alpha^2 + 0.0542*alpha - 0.5037;
                elseif(alpha > 27 && alpha <= 90)
                    Cl = -.00000009*alpha^4 + .00003*alpha^3 - 0.0036*alpha^2 + 0.1761*alpha - 1.8521;

                %FINDING CD
                if(alpha >= 0 && alpha <= 8)
                    Cd = -.00001*alpha^3 + 0.0003*alpha^2 - 0.0003*alpha + 0.0134;
                elseif(alpha > 8 && alpha <= 90)
                    Cd = -.0000000004*alpha^5 + .0000002*alpha^4 - .00003*alpha^3 + 0.0018*alpha^2 - 0.0196*alpha + 0.1616;
                    Cd = 0;
  2. jcsd
  3. Nov 13, 2008 #2
    Locate your data file in Matlab's 'Current Directory' window. Right-click on the file and select 'Import Data'. The use the GUI to import the data into matlab.

    Matlab's documentation discusses interpolation and fitting at great length. Use the help browser to search for 'Interpolation'.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook