Reading Excel XY Data and Interpolate
3 views (last 30 days)
I have +60k of X(time) and Y(position) data of a wave in excel. To read them I used xlsread comand. X=xlsread('A1Wave','A3:A65554'); Y=xlsread('A1Wave','B3:B65554');
I now need to interpolate them to find the function that goes through those points. How do I do this? What function do I use?
I also have to get the wave periods. Is there a way to have matlab calculate them? I mean, give me the list of values of when the function goes from negative to positive?
Matt Tearle on 16 Oct 2014
This is a pretty huge question -- it really depends what you're assuming about the data and, consequently, what you're trying to fit to it. In general, though, if the data represents a wave signal, you probably want to do an FFT to get the frequencies.
If, however, you know it's just a single frequency wave, then, to answer your specific question about getting the periods, you can do something like this:
% Generate some data (a single-frequency wave)
w = rand;
x = linspace(0,20,501);
y = sin(2*pi*w*x);
% Find where the signal goes from positive to negative
zerocross = (y(1:end-1)>0) & (y(2:end)<0);
periods = diff(x(zerocross))
% Get the mean period and compare to what it should be
One last side point: two calls to xlsread is unnecessarily slow. Get x and y together and split them in MATLAB:
data = xlsread('A1Wave','A3:B65554');
X = data(:,1);
Y = data(:,2);