How to calculate center of pressure given a 2d array containing pressure data

28 visualizaciones (últimos 30 días)
So as the title says I want to know how to calculate the center of pressure coordinates given that the input will be a 2d matrix with each element representing a "pressure grid".
  3 comentarios
the cyclist
the cyclist el 13 de Mzo. de 2024
Editada: the cyclist el 13 de Mzo. de 2024
Do elements with index 1,2,3 ... representing points that are equally spaced in the "real world"? Is the spacing the same along the two dimensions?
Alex
Alex el 13 de Mzo. de 2024
I wish to calculate xc and yc based on the discrete version of this formula xc = sum(x*p)/sum(p), yc = sum(y*p)/sum(p). For context each element will represent pressure data from one sensor of a pressure plate, so i guess the question is how do I determine which x and y values to use. The way I understand it is that x&y are distances from a reference point so can I just choose one arbitrarily?

Iniciar sesión para comentar.

Respuesta aceptada

the cyclist
the cyclist el 13 de Mzo. de 2024
Editada: the cyclist el 13 de Mzo. de 2024
If the answers to both of the questions in my comment is "yes", then
% Example input
pressureArray = [1 2 3;
4 5 6;
7 8 9]
pressureArray = 3x3
1 2 3 4 5 6 7 8 9
% Get array size
[rows, cols] = size(pressureArray);
% Total pressure
totalPressure = sum(pressureArray,"all");
% Calculate moments about x and y axes
momentX = sum((1:cols) .* pressureArray,"all");
momentY = sum((1:rows)' .* pressureArray,"all");
% Calculate center of pressure
COP_x = momentX / totalPressure
COP_x = 2.1333
COP_y = momentY / totalPressure
COP_y = 2.4000
The "spatial" coordinates are the indexing of the array (in this case 1:3 along both directions). You may need to apply a multiplier, or translation operation.

Más respuestas (1)

Image Analyst
Image Analyst el 14 de Mzo. de 2024
If you have the Image Processing Toolbox (I think most people do) then you can do it in one line of code by asking regionprops to compute the weighted centroid.
% Example input from the cyclist
pressureArray = [1 2 3;
4 5 6;
7 8 9];
% Using regionprops to compute the weighted centroid. Requires Image Processing Toolbox.
props = regionprops(true(size(pressureArray)), pressureArray, 'WeightedCentroid')
props = struct with fields:
WeightedCentroid: [2.1333 2.4000]
  2 comentarios
Alex
Alex el 14 de Mzo. de 2024
Thanks! this method definitely works, it gives the same output as the solution provided by the cyclist.
Image Analyst
Image Analyst el 14 de Mzo. de 2024
Editada: Image Analyst el 14 de Mzo. de 2024
Yes, and my way is a lot simpler.

Iniciar sesión para comentar.

Categorías

Más información sobre Logical en Help Center y File Exchange.

Productos


Versión

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by