matrix, where each element is a column vector
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentario
Stephen23
el 4 de Mayo de 2024
Please upload your data in a MAT file, by clicking the paperclip button.
Respuestas (2)
John D'Errico
el 4 de Mayo de 2024
Editada: John D'Errico
el 4 de Mayo de 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 comentario
Image Analyst
el 4 de Mayo de 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
el 4 de Mayo de 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 comentarios
Ver también
Categorías
Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!