Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Volume calculation for a 4d matrix

Subject: Volume calculation for a 4d matrix

From: Claire

Date: 28 Jul, 2010 05:59:05

Message: 1 of 2

I have a 4D dataset comprised of latitude, longitude, depth and time for the Southern Ocean. I have analysed my dataset in order to determine the locations of different water masses within the original dataset based on temperature and salinity properties.

What I now have is a 4D matrix 'AABWyn1', which has 0 or 1 values within the 4D grid depending on if the grid point meets my criteria.

What I want to do is find the number of '1's in my 4D grid. I have tried using the 'find' and 'sum' commands, but these don't seem to give me what I want - they seem to not work in 4D.

Secondly, I can visualise in my head my 3D grid for each time period as a series of cubes, within latitude, longitude and depth coordinates. What I want to do is find the volume of these cubes that have a '1'. I.e. I want to sum up the number of cubes that have the value '1' at all their vertices in order to determine the volume of the water mass for each time period. I can then use the scales of each of the 3D axes to work out my real volumes.

I have no idea how to do either of these things and I would really appreciate any help anyone can offer.

Thanks in advance,
Claire

Subject: Volume calculation for a 4d matrix

From: Matt J

Date: 28 Jul, 2010 06:17:07

Message: 2 of 2

"Claire " <claire.davis@students.mq.edu.au> wrote in message <i2ogv9$n1n$1@fred.mathworks.com>...
> I have a 4D dataset comprised of latitude, longitude, depth and time for the Southern Ocean. I have analysed my dataset in order to determine the locations of different water masses within the original dataset based on temperature and salinity properties.
>
> What I now have is a 4D matrix 'AABWyn1', which has 0 or 1 values within the 4D grid depending on if the grid point meets my criteria.
>
> What I want to do is find the number of '1's in my 4D grid. I have tried using the 'find' and 'sum' commands, but these don't seem to give me what I want - they seem to not work in 4D.
================

Doing either nnz(AABWyn1) or sum(AABWyn1(:)) should work for this part.



> Secondly, I can visualise in my head my 3D grid for each time period as a series of cubes, within latitude, longitude and depth coordinates. What I want to do is find the volume of these cubes that have a '1'. I.e. I want to sum up the number of cubes that have the value '1' at all their vertices in order to determine the volume of the water mass for each time period. I can then use the scales of each of the 3D axes to work out my real volumes.
============

Are you sure you mean all their "vertices"? You mean there are 1s at the corners of the cube, but nowhere else? If you have the image processing toolbox, bwconncomp and regionprops should help.

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us