Avoiding for loop for 1d-intepolation
2 ビュー (過去 30 日間)
Generally, I try to avoid for loops. Is there any way of avoiding the following for loop?
result(ii) = interp1(Eng_mat,res(:,ii),alpha(ii),'linear', 'extrap');
Dimension of the matrices: Eng_mat is 4000*1, res is 4000*10, alpha is 10*1
In principle, I need to use interpolation for each element of alpha according to ii'th coloumn of res.
I appreciate it if someone could help me with this.
回答 (1 件)
Image Analyst 2022 年 5 月 21 日
I don't see a simpler way off the top of my head. You have only 10 iterations so I wouldn't worry about it. Ten iterations of a for loop will probably be faster than any other way you'd do it. If you had tens of millions of iterations then maybe it would be time to worry about a for loop, but for 10? Don't worry about it.