Interpolating [3,3] matrix valued function using interp3
1 回表示 (過去 30 日間)
古いコメントを表示
Hello everyone
I have a [3,3] matrix valued function that I would like to interpolate using interp3 if that is possible. The sampled function is given in the form of a [N,N,N,3,3] matrix similar to the code sample below:
N=25;
coords=linspace(0,1,N);
[X,Y,Z]=meshgrid(coords,coords,coords);
values=zeros(N,N,N,3,3);
for i=1:1:N
for j=1:1:N
for k=1:1:N
values(i,j,k,:,:)=rand(3,3);
end
end
end
f=@(x,y,z) interp3(X,Y,Z,values,x,y,z);
f(0.5,0.5,0.5)
I'm not quite sure how I should go about using interp3 to interpolate said function?
0 件のコメント
回答 (1 件)
Rishabh Singh
2021 年 11 月 5 日
Below code should work, and provide you the required output.
N=25;
coords=linspace(0,1,N);
[X,Y,Z]=ndgrid(coords,coords,coords);
values=zeros(N,N,N,3,3);
for i=1:1:N
for j=1:1:N
for k=1:1:
values(i,j,k,:,:) = rand(3,3);
end
end
end
f=@(x,y,z) interpn(X,Y,Z,values,x,y,z);
output = squeeze(f(0.5,0.5,0.5))
Hope this helps.
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!