Interpolating data in a better way?
Show older comments
I will simplify this down, as my data is huge. I have about 100 sets of data smaller than the one I am going up to; each one of them vary in size. IE 3x6 or 9x9. I need to interpolate it up to say 20x20. Names of variables were changed for simplicity also.
A 3x3 raw data would look like this, and cannot change (easily) as I am importing from an edit locked file.
rawdata=[1 7 3 ;8 9 6; 2 2 5];
Here is how am currently going about it.
g_raw = size(rawdata);
xg_g = linspace(1,20,g_raw(1));
yg_g = linspace(1,20,g_raw(2));
interp_x_g = interp1(xg_g, g_raw, 1:20); %doing one direction
interp_y_g = interp1(yg_g, interp_x_g', 1:20)'; %tackling other direction with a transpose and transpose back
interpolated_g = interp_y_g(:); %making into a vector for plotting vs another vector
It works in a sense, but comes out very choppy. Is there a better way? I have been using MatLab for about a week and getting the hang of it. I just do not understand everything in the help files. IE I could not get polyfit to work in my loops. Not sure if I should be using interp2 or 3? All help is appreciated, even if it is just correcting syntax or general advice.
Cheers!
Walt
Accepted Answer
More Answers (0)
Categories
Find more on Resizing and Reshaping Matrices 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!