How to calculate the volume of a 3D plot defined by a matrix

조회 수: 1 (최근 30일)
Wissem
Wissem 2021년 12월 16일
댓글: Wissem 2021년 12월 16일
Hi everyone,
So basically, I am trying to calculate a volume. More precisely, I have a height field that is defined in every point of a 2D plane and nammed "h_real" in my code. This quantity is a 3D matrix because each height field is computed at every timestamp so for each time frame corresponds a given height field.
I would like to estimate the evolution of the volume associated to the height's progression during the considered time period (which is the length of the 3D matrix). I have tried this script but the result obtained is not accurate...
Could someone help me to find a new strategy to do so please ?
Thank you in advance
for i = 1:length(h_real)
volume(i) = sum(h_real(:,:,i),'all')*(scale^2)*(1e6);
plot(volume)
ylabel('Volume (ml)')
xlabel('Number of images')
title('Evolution du volume au cours du temps');
end

채택된 답변

Matt J
Matt J 2021년 12월 16일
편집: Matt J 2021년 12월 16일
It looks fine, though I would do it this way:
volume=reshape( sum(h_real,[1,2]), 1,[])*(scale^2)*(1e6);
plot(volume)
ylabel('Volume (ml)')
xlabel('Number of images')
title('Evolution du volume au cours du temps');
  댓글 수: 3
Matt J
Matt J 2021년 12월 16일
편집: Matt J 2021년 12월 16일
So you think that if this method doesn't give me a relevant result it's because there is something wrong with my initial data "h_real" ?
Yes.
Don't you think that using the "sum" function is a little bit wrong in a certain way ?
Not if your data is smooth. You might be able to do a bit better with trapz().
volume=reshape( trapz(trapz(h_real,1),2), 1,[])*(scale^2)*(1e6);
Wissem
Wissem 2021년 12월 16일
Thank you for your answers : it helps me to reconsider again my initial experimental results.
Best regards.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Numerical Integration and Differentiation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by