how to Plot the time it took to compute the bubble sort versus the number of value in a particular array.

i'm working on a bubble sort problem that i cannot figure out. I have created a function that will do the bubble sort, it displays an array after its sorted and also the time it took to do this proccess. This is all in a function.
Now i'm a script where i had to created an "unsorted" array of n random integrers. where n is 1 to 1000. but i have to plot the time it takes to compute the bubble sort vs the number of value in that array. i know how to plot the values in my array based on my function but idk how to time that.
for n = 1:1000 unsorted = 10*rand(1,n); end
plot(Pablo_bubbleSort(unsorted),'bs')
here is what i have i need the time in there somehow and i just can't get it.

Answers (1)

Use timeit()
If you have a sufficiently new version of MATLAB then it is built in; if not then get it from the File Exchange.

Categories

Asked:

on 3 Sep 2015

Answered:

on 4 Sep 2015

Community Treasure Hunt

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

Start Hunting!