Is it possible to create an 'average' matrix from inputs of matrices of varying sizes?

1 Ansicht (letzte 30 Tage)
The motivation for this question comes from one 3D matrix represents the coordinates of a cat walking through time.
Each matrix representing a cat takes on the form Matrix = [#points representing cat, x and y coordinate positions, #of frames]. The x and y coordinates comprising the cat is plotted succesively over each frame.
For example:
Cat 1(14, 2, 100)
Cat2(13, 2, 200)
Cat3(16, 2, 300)
My quesiton is whether there is a way to 'combine' all 3 cats so that I have one 'avg' cat? Maybe:
Cat_avg = (14, 2, 200) -> which is represented exclusively by the previous inputs?
Is such a thing possible? Would I have to augment smaller matricies w/ zeros or NaNs to do something like this? Apologies in advance if this is trivial; I have not yet taken linear algebra so am unsure if there is a simple way to do this, so am coming to this community for help. Thanks!

Antworten (1)

yanqi liu
yanqi liu am 22 Nov. 2021
sir,may be use reshape to vector,but its order is confuse,such as
clc; clear all; close all;
Cat1 = 1*ones(14, 2, 100);
Cat2 = 2*ones(13, 2, 200);
Cat3 = 3*ones(16, 2, 300);
Cat_all = cat(1, Cat1(:), Cat2(:), Cat3(:));
  1 Kommentar
Emmanuel Osikpa
Emmanuel Osikpa am 23 Nov. 2021
Hmm, I see what you mean with this; I think I can keep track of locations in my workspace and reshape with the corresponding coordinates. Thank you for your quick response! I will come back with update as to how this worked out

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by