matrix, where each element is a column vector
3 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (2 件)
John D'Errico
2024 年 5 月 4 日
編集済み: John D'Errico
2024 年 5 月 4 日
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 件のコメント
Image Analyst
2024 年 5 月 4 日
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
2024 年 5 月 4 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!