Extract same data points from long vector to fit shorter vector
Show older comments
Hello, I've built a model for a glacier, which I now want to test with real data.
My entire script is based on vectors and matrices of lengths 1001. The length of the real data I've collected is 10007.
I can't rewrite my script to be based on 10007 indexes - my computer can not handle it. I've been told, I can "interpolate", which is a function I haven't used before and haven't found exampels on people using it on going from larger datasets to lower ones. It's important that I take out the same indexes for every vector so the points matches.
So, to begin with I have this:
n=1001;
dx=1000; %step size
% grid along x-axis
x=zeros(n,1);
for i=1:n
x(i,1)=((i-1)*dx);
end
%Bottom Topography
b0 = 300;
slope = 0.0015;
lambd = 300;
xss = 620000;
sigma = 80000;
for i=1:n
bed(i,1) = b0-slope*x(i)+lambd*exp(-((x(i)-xss)/(sigma))^2);
end
That's the grid and bottom topography for my model.
This is what I was thinking, which is really simple and I avoid the use of interpolation.
%FLdist is the real world data for the x-grid (similar to x)
FLdist1 = FLdist(1:10:end);
%Likewise for FLbed
FLbed1 = FLbed(1:10:end);
I just take every 10th point for the vector and end up with a vector 1001 indexes and I must assume I get the corresponding values, because the plot looks very similar.
Is this an acceptable way of doing it?
-Mikkel
Answers (0)
Categories
Find more on Interpolation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!