matrix, where each element is a column vector
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Excuse me, I need some help. I have an 11*7 matrix. Each element of this matrix consists of a column vector 1001*1. I want to calculate for each column matrix the maximum value. thanks for your help
ETATT=cell(11,7); % initial matrix
Etat=zeros(1001,1); % column vector, contained in each element of the ETATT matrix
I want to find the maximum value of each Etat contained in ETATT
THANKS
1 commentaire
Réponses (2)
John D'Errico
le 4 Mai 2024
Modifié(e) : John D'Errico
le 4 Mai 2024
You don't need a cell array at all!
Just use a 3-d array.
A = randn(11,7,1001);
Now to compute the max in each vector, just use max.
Amax = max(A,[],3)
You can extract any vector from Amax simply enough.
v = Amax(i,j,:);
This will be a 1x1x1001 vector. If you want it to be a true column vector, then just do
v = squeeze(A(i,j,:));
Or, you can store the array as a 1001x11x7 array. Now you can extract the (i,j) vector as
V = rand(1001,11,7);
V(:,1,2)
1 commentaire
Image Analyst
le 4 Mai 2024
John's absolutely right. Don't complicate things by using a cell array if you don't have to, and from what you've said so far, it doesn't appear you have to.
the cyclist
le 4 Mai 2024
ETATT=cell(11,7); % initial matrix
Etat=zeros(1001,1); % column vector, contained in each element of the ETATT matrix
% Fill each cell with a random column vector
for ii=1:11
for jj=1:7
ETATT{ii,jj} = rand(1001,1);
end
end
% Find the max of each vector
maxEtat = cellfun(@max,ETATT);
0 commentaires
Voir également
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!