Finding points inbetween the values of my arrays.
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Jordan Coombs
am 5 Jan. 2021
Kommentiert: Jordan Coombs
am 6 Jan. 2021
I have five arrays each containing data for information at five year intervals (2000,2005,2010,2015,2020) i need to use this data to create data for all the years inbetween while maintaining the structure of the array. The array is a 4320x8640 single. I would prefer to take all points into account so the function would not be made of many straight lines, however if there is no way to do that it would be acceptable.
0 Kommentare
Akzeptierte Antwort
Daniel Pollard
am 5 Jan. 2021
If I understand your question, you want the interp1 command. You can choose how many target points to create, so make the lines as smooth as you want.
However, that will perform over 37 million interpolations. That's a lot, so will take a long time, but hopefully you realised that when you asked the question.
5 Kommentare
Daniel Pollard
am 6 Jan. 2021
My first thought would be to use a nested loop. So you have five arrays, let's call them A00, A05, A10, A15, A20. Each array has the size 4320x8640. So we could set up a loop which looks like
for ii = 1:4320
for jj = 1:8640
data_vec = [A00[ii, jj], A05[ii, jj], A10[ii, jj], A15[ii, jj], A20[ii, jj]];
interp_data = interp1(data_vec, linspace(0, 20, 21));
% Then some line which saves interp_data to an array,
% which you have preallocated.
end
end
I haven't tested this, so it might not work straight out of the box, but it certainly should get you going in the right direction. I'll reiterate though, that this code will be extremely slow. If you have the parallel computing toolbox, maybe you could use a parfor loop to speed things up a bit.
I'm sure there's a more efficient way to write this code. Hopefully this helps. Remember to look at the documentation if you get stuck, it really is great for Matlab.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!