gridding problems in the script

조회 수: 1 (최근 30일)
Vadim Tambovtsev
Vadim Tambovtsev 2016년 10월 27일
답변: KSSV 2016년 10월 27일
Hello,
in the task I have an independent-of-grid "real size" set of good sand inside a volume. The task is to make gridding on this set, convert in to 100x50x50 grid, to 64x32x32 grid etc.
I managed to make this script, but the "good-sand" fractions differs a lot depending on the chosen grid, but it should be almost the same. Could you find an error in my script?
Thank you.
  댓글 수: 1
KSSV
KSSV 2016년 10월 27일
A is dependent on what variables? Specifically do you have x and y values for the grid?

댓글을 달려면 로그인하십시오.

채택된 답변

KSSV
KSSV 2016년 10월 27일
You can reduce your A of size 100x50x50 to 64x32x32 using the following code:
%%do spatial inteprolation to reduce A spatially
[m,n,p] = size(A) ;
x = linspace(0,1,n) ;
y = linspace(0,1,m) ;
[X,Y] = meshgrid(x,y) ;
% Reduce A spatially
xi = linspace(0,1,32) ;
yi = linspace(0,1,64) ;
[Xi,Yi] = meshgrid(xi,yi) ;
%
Ar = zeros(64,32,p) ;
for i = 1:p
Ar(:,:,i) = interp2(X,Y,A(:,:,i),Xi,Yi) ;
end
%%Reduce thrid dimension
t = linspace(0,1,p) ;
ti = linspace(0,1,32) ;
Areduced = zeros(64,32,32) ;
for i = 1:64
for j = 1:32
Arij = squeeze(Ar(i,j,:)) ;
Areducedij = interp1(t,Arij,ti) ;
% replace values
Areduced(i,j,:) = Areducedij ;
end
end
Areduced is your A with new dimensions of 64X32X32.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by