Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Find Minimum Values of Matrix without MIN or For loops

Subject: Find Minimum Values of Matrix without MIN or For loops

From: Stephen Smitherman

Date: 1 May, 2011 02:40:06

Message: 1 of 1

I am reviewing for a test and my teacher loves to ask us questions that require the removal of explicit loops (FOR and WHILE) and use implicit (Array Operations) instead. For example instead of

for n=1:100
     b=sin(n);
end
b

instead use

n=1:100;
b=sin(n);
b

so the function we are to convert is as follows
A is an arbitrary predifined Matrix

clear,clc
for m=1:length(A(1,:));
    S(m)=A(1,m);
    for k=2:length(A(:,1));
         if(S(m)>A(k,m))
                S(m)=A(k,m);
         end
     end
end
S

Where S is a vector with the minimum value of each column.
I know this could be solved with Min(A), but that is not what is being ask. How would I use vectorization to make the same above operation to work?

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us