I need help about writing a script to get a vector consisting of Max and min for each column in a matrix.

Antworten (1)

A= [1 2 3;4 5 6; 7 8 9]
B=[min(A(:,1)) max(A(:,2)) min(A(:,3))]
But in your case you mean max or min in rows, not in column.
B=[min(A(1,:)) max(A(2,:)) min(A(3,:))]
If your matrix is big
A= [1 2 3;4 5 6; 7 8 9];
B=zeros(1,size(A,2));
B(1:2:end)=min(A(1:2:end,:),[],2)';
B(2:2:end)=max(A(2:2:end,:),[],2)'

Kategorien

Mehr zu Aerospace Blockset finden Sie in Hilfe-Center und File Exchange

Tags

Gefragt:

am 22 Jun. 2015

Bearbeitet:

am 22 Jun. 2015

Community Treasure Hunt

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

Start Hunting!

Translated by