Path: news.mathworks.com!not-for-mail
From: "Evren " <evrenbrs@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: sorting algorithm
Date: Wed, 3 Dec 2008 15:48:02 +0000 (UTC)
Organization: YTU
Lines: 16
Message-ID: <gh69ni$6gv$1@fred.mathworks.com>
Reply-To: "Evren " <evrenbrs@gmail.com>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1228319282 6687 172.30.248.35 (3 Dec 2008 15:48:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 3 Dec 2008 15:48:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1626124
Xref: news.mathworks.com comp.soft-sys.matlab:504706


Hi I am in a matlab course and the teacher wants us to create a function in MATLAB 7.5.0(R2007b) that does the following 
A. Using the input command, you enter a set of number to be sorted as a row vector. the length of the vector is arbitrary. 
B. You program should then sort the numbers from the most negative to the most positive. 
C. You program should then print out the unsorted list and the sorted list. 
D. You can't use the built in matlab sort function to complete this assignmen. You must develop your own sorting algorithm. 

I tried for hours and just can't seem to get it and its do tomorrow. If anyone can help, thank you very much. 

Here is what I got so far with some help, but it still doesn't work.

for i=1:(n-1)  % n is the length of the vector V 
            if V(i)>V(i+1) 
                    s = V(i); V(i) = V(i+1); V(i+1) = s; 
            end 
end