Be the first to rate this file! 23 Downloads (last 30 days) File Size: 1.15 KB File ID: #33054
image thumbnail

Array sorting

by

 

28 Sep 2011 (Updated )

Program for Sorting of Array in Matlab

| Watch this File

File Information
Description

This Example will help you in getting the basics of programmatic as well
As the various commands used in matlab, Use of Loops, Use of Conditional
statements Etc...

Here is the surprise, Matlab has an inbuilt function called 'sort' for sorting any array.

Required Products MATLAB Compiler
MATLAB release MATLAB 7.10 (R2010a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (2)
29 Sep 2011 satendra kumar

@jan: Thanks for your valuable comment.
I have updated this file to a user oriented function.
Further Comments and queries are dearly invited.

29 Sep 2011 Jan Simon

This is not a good programming example. The "clear all" is useless here and removing all loaded fucntions from the memory is a waste of time and energy. Even the less brute "clear variables" cannot be recommended here: Better check you code, if all uses variables are defined. If they are, the unconditional clearing is inefficient.
Does "nos" mean "numbers"?
Do you see, that "a" is underlined by MLint? This means, that MATLAB found out, that this command is inefficient, because you do not pre-allocate "a". Just hold the mouse over the underlined symbol to learn more about MLint.
The sorting algorithm is inefficient, but the implementation is not clean: There is no reason to run the FOR loop over i until 5.
It would be much nicer, if the data length is not fixed to 5, but can be changed by the user through an input. I'd prefer to convert this to a function, instead of a script.

Updates
29 Sep 2011

I have updated the Script file to a Function called 'Array_sort'. Which is more user input oriented, with a variable size of array.
Upon calling this function in matlab command window it will ask for the user input data.

Contact us