Finding points inbetween the values of my arrays.
6 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
Daniel Pollard
2021 年 1 月 5 日
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 件のコメント
Daniel Pollard
2021 年 1 月 6 日
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.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!