lab5 - CSC 113 Fall 2010 Lab Assignment 5 1 Write a M ATLAB...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CSC 113, Fall 2010 Lab Assignment 5 1. Write a M ATLAB function file that that sorts a vector of numbers from the smallest to the largest, without using the M ATLAB sort command. The input to the program should be a vector containing the values to sort, and the output should be a vector of the same size, containing the sorted values. 2. Consider a character array containing names having different lengths, created using the char() function: >> NameArray = char(’Holly’,’Steven’,’Meagan’,’David’,’Micheal’,’andy’) This will create a 6 × 7 array, with NameArray(2,1) containing the character S, and NameArray(2,2) containing the character t, and so on. Write a M ATLAB script (not function) which sorts the names in alphabetical order, with the result stored in an array called SortedNames: % Script to sort names % % Set up initial array: % NameArray = char(’Holly’,’Steven’,’Meagan’,’David’,’Micheal’,’andy’); % % Initialize output array: % SortedNames = NameArray; % % Sort the entries of SortedNames into alphabetical order: % (Your code goes here) ...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online