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

Solution 157627

Submitted on 4 Nov 2012 by Jon Danisch

Correct

20Size
Leading solution size is 10.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
Code Input and Output
1
Pass
 
%%
x = sort(rand(1,10^5));
y_correct = 1;
assert(isequal(sortok(x),y_correct))
y =
  Columns 1 through 6
    0.0000    0.0000    0.0000    0.0000    0.0000    0.0001
  Columns 7 through 12
    0.0001    0.0001    0.0001    0.0001    0.0001    0.0001
  Columns 13 through 18
    0.0001    0.0001    0.0001    0.0001    0.0001    0.0001
  Columns 19 through 24
    0.0001    0.0002    0.0002    0.0002    0.0002    0.0002
  Columns 25 through 30
    0.0002    0.0002    0.0002    0.0002    0.0002    0.0002
  Columns 31 through 36
    0.0002    0.0003    0.0003    0.0003    0.0003    0.0003
  Columns 37 through 42
    0.0003    0.0003    0.0003    0.0003    0.0004    0.0004
  Columns 43 through 48
    0.0004    0.0004    0.0004    0.0004    0.0004    0.0004
  Columns 49 through 54
    0.0004    0.0005    0.0005    0.0005    0.0005    0.0005
  Columns 55 through 60
    0.0005    0.0006    0.0006    0.0006    0.0006    0.0006
  Columns 61 through 66
    0.0006    0.0006    0.0006    0.0006    0.0006    0.0007
  Columns 67 through 72
    0.0007    0.0007    0.0007    0.0007    0.0007    0.0007
  Columns 73 through 78
    0.0007    0.0007    0.0007    0.0007    0.0007    0.0008
  Columns 79 through 84
    0.0008    0.0008    0.0008    0.0008    0.0008    0.0008
  Columns 85 through 90
    0.0009    0.0009    0.0009    0.0009    0.0010    0.0010
  Columns 91 through 96
    0.0010    0.0010    0.0010    0.0010    0.0010    0.0010
  Columns 97 through 102
    0.0010    0.0010    0.0010    0.0010    0.0010    0.0010
  Columns 103 through 108
    0.0011    0.0011    0.0011    0.0011    0.0011    0.0011
  Columns 109 through 114
    0.0011    0.0011    0.0011    0.0011    0.0011    0.0011
  Columns 115 through 120
    0.0012    0.0012    0.0012    0.0012    0.0012    0.0012
  Columns 121 through 126
    0.0012    0.0012    0.0012    0.0012    0.0013    0.0013
  Columns 127 through 132
    0.0013    0.0013    0.0013    0.0013    0.0013    0.0013
  Columns 133 through 138
    0.0013    0.0013    0.0013    0.0013    0.0013    0.0013
  Columns 139 through 144
    0.0013    0.0014    0.0014    0.0014    0.0014    0.0014
  Columns 145 through 150
    0.0014    0.0014    0.0015    0.0015    0.0015    0.0015
  Columns 151 through 156
    0.0015    0.0015    0.0015    0.0015    0.0015    0.0015
  Columns 157 through 162
    0.0015    0.0015    0.0016    0.0016    0.0016    0.0016
  Columns 163 through 168
    0.0016    0.0016    0.0016    0.0016    0.0016    0.0016
  Columns 169 through 174
    0.0016    0.0016    0.0017    0.0017    0.0017    0.0017
  Columns 175 through 180
    0.0017    0.0017    0.0017    0.0017    0.0017    0.0017
  Columns 181 through 186
    0.0017    0.0017    0.0018    0.0018    0.0018    0.0018
  Columns 187 through 192
    0.0018    0.0018    0.0018    0.0018    0.0018    0.0018
  Columns 193 through 198
    0.0018    0.0018    0.0018    0.0018    0.0019    0.0019
  Columns 199 through 204
    0.0019    0.0019    0.0019    0.0019    0.0019    0.0019
  Columns 205 through 210
    0.0019    0.0020    0.0020    0.0020    0.0020    0.0020
  Columns 211 through 216
    0.0021    0.0021    0.0021    0.0021    0.0021    0.0021
  Columns 217 through 222
    0.0022    0.0022    0.0022    0.0022    0.0022    0.0022
  Columns 223 through 228
    0.0022    0.0022    0.0023    0.0023    0.0023    0.0023
  Columns 229 through 234
    0.0023    0.0023    0.0023    0.0023    0.0023    0.0023
  Columns 235 through 240
    0.0024    0.0024    0.0024    0.0024    0.0024    0.0024
  Columns 241 through 246
    0.0024    0.0024    0.0025    0.0025    0.0025    0.0025
  Columns 247 through 252
    0.0025    0.0025    0.0025    0.0025    0.0025    0.0025
  Columns 253 through 258
    0.0025    0.0025    0.0025    0.0025    0.0025    0.0025
  Columns 259 through 264
    0.0026    0.0026    0.0026    0.0026    0.0026    0.0026
  Columns 265 through 270
    0.0026    0.0026    0.0026    0.0027    0.0027    0.0027
  Columns 271 through 276
    0.0027    0.0027    0.0027    0.0027    0.0027    0.0027
  Columns 277 through 282
    0.0027    0.0028    0.0028    0.0028    0.0028    0.0028
  Columns 283 through 288
    0.0028    0.0028    0.0028    0.0028    0.0028    0.0029
  Columns 289 through 294
    0.0029    0.0029    0.0029    0.0029    0.0029    0.0029
  Columns 295 through 300
    0.0029    0.0029    0.0029    0.0030    0.0030    0.0030
  Columns 301 through 306
    0.0030    0.0030    0.0030    0.0031    0.0031    0.0031
  Columns 307 through 312
    0.0031    0.0031    0.0031    0.0031    0.0031    0.0031
  Columns 313 through 318
    0.0031    0.0031    0.0031    0.0031    0.0031    0.0032
  Columns 319 through 324
    0.0032    0.0032    0.0032    0.0032    0.0032    0.0032
  Columns 325 through 330
    0.0032    0.0033    0.0033    0.0033    0.0033    0.0033
  Columns 331 through 336
    0.0033    0.0033    0.0033    0.0033    0.0033    0.0033
  Columns 337 through 342
    0.0034    0.0034    0.0034    0.0034    0.0034    0.0034
  Columns 343 through 348
    0.0034    0.0034    0.0034    0.0034    0.0035    0.0035
  Columns 349 through 354
    0.0035    0.0035    0.0036    0.0036    0.0036    0.0036
  Columns 355 through 360
    0.0036    0.0036    0.0036    0.0036    0.0036    0.0036
  Columns 361 through 366
    0.0036    0.0036    0.0037    0.0037    0.0037    0.0037
  Columns 367 through 372
    0.0037    0.0038    0.0038    0.0038    0.0038    0.0038
  Columns 373 through 378
    0.0039    0.0039    0.0039    0.0039    0.0039    0.0039
  Columns 379 through 384
    0.0039    0.0039    0.0039    0.0039    0.0040    0.0040
  Columns 385 through 390
    0.0040    0.0040    0.0040    0.0040    0.0040    0.0041
  Columns 391 through 396
    0.0041    0.0041    0.0041    0.0041    0.0041    0.0041
  Columns 397 through 402
    0.0041    0.0041    0.0041    0.0041    0.0041    0.0042
  Columns 403 through 408
    0.0042    0.0042    0.0042    0.0043    0.0043    0.0043
  Columns 409 through 414
    0.0043    0.0043    0.0043    0.0043    0.0044    0.0044
  Columns 415 through 420
    0.0044    0.0044    0.0044    0.0044    0.0044    0.0044
  Columns 421 through 426
    0.0044    0.0044    0.0044    0.0044    0.0044    0.0044
  Columns 427 through 432
    0.0045    0.0045    0.0045    0.0045    0.0045    0.0045
  Columns 433 through 438
    0.0045    0.0045    0.0045    0.0046    0.0046    0.0046
  Columns 439 through 444
    0.0046    0.0046    0.0046    0.0046    0.0046    0.0046
  Columns 445 through 450
    0.0046    0.0046    0.0046    0.0046    0.0046    0.0046
  Columns 451 through 456
    0.0047    0.0047    0.0047    0.0047    0.0047    0.0047
  Columns 457 through 462
    0.0047    0.0047    0.0047    0.0047    0.0047    0.0047
  Columns 463 through 468
    0.0048    0.0048    0.0048    0.0048    0.0048    0.0048
  Columns 469 through 474
    0.0048    0.0048    0.0048    0.0049    0.0049    0.0049
  Columns 475 through 480
    0.0049    0.0049    0.0049    0.0049    0.0049    0.0049
  Columns 481 through 486
    0.0049    0.0049    0.0049    0.0049    0.0050    0.0050
  Columns 487 through 492
    0.0050    0.0050    0.0050    0.0050    0.0050    0.0050
  Columns 493 through 498
    0.0050    0.0050    0.0050    0.0051    0.0051    0.0051
  Columns 499 through 504
    0.0051    0.0051    0.0051    0.0051    0.0051    0.0051
  Columns 505 through 510
    0.0051    0.0051    0.0052    0.0052    0.0052    0.0052
  Columns 511 through 516
    0.0052    0.0052    0.0052    0.0052    0.0053    0.0053
  Columns 517 through 522
    0.0053    0.0053    0.0053    0.0053    0.0053    0.0053
  Columns 523 through 528
    0.0053    0.0054    0.0054    0.0054    0.0054    0.0054
  Columns 529 through 534
    0.0054    0.0054    0.0054    0.0054    0.0055    0.0055
  Columns 535 through 540
    0.0055    0.0055    0.0055    0.0055    0.0055    0.0055
  Columns 541 through 546
    0.0055    0.0056    0.0056    0.0056    0.0056    0.0056
  Columns 547 through 552
    0.0056    0.0056    0.0056    0.0056    0.0056    0.0057
  Columns 553 through 558
    0.0057    0.0057    0.0057    0.0057    0.0057    0.0057
  Columns 559 through 564
    0.0057    0.0057    0.0057    0.0057    0.0058    0.0058
  Columns 565 through 570
    0.0058    0.0058    0.0058    0.0058    0.0058    0.0058
  Columns 571 through 576
    0.0058    0.0058    0.0059    0.0059    0.0059    0.0059
  Columns 577 through 582
    0.0059    0.0059    0.0059    0.0059    0.0059    0.0059
  Columns 583 through 588
    0.0059    0.0059    0.0060    0.0060    0.0060    0.0060
  Columns 589 through 594
    0.0060    0.0060    0.0060    0.0060    0.0060    0.0060
  Columns 595 through 600
    0.0060    0.0060    0.0060    0.0060    0.0060    0.0061
  Columns 601 through 606
    0.0061    0.0061    0.0061    0.0061    0.0061    0.0061
  Columns 607 through 612
    0.0061    0.0061    0.0062    0.0062    0.0062    0.0062
  Columns 613 through 618
    0.0062    0.0062    0.0062    0.0062    0.0062    0.0062
  Columns 619 through 624
    0.0062    0.0062    0.0062    0.0063    0.0063    0.0063
  Columns 625 through 630
    0.0063    0.0063    0.0063    0.0063    0.0064    0.0064
  Columns 631 through 636
    0.0064    0.0064    0.0064    0.0064    0.0064    0.0064
  Columns 637 through 642
    0.0064    0.0064    0.0064    0.0065    0.0065    0.0065
  Columns 643 through 648
    0.0065    0.0065    0.0065    0.0065    0.0065    0.0065
  Columns 649 through 654
    0.0065    0.0065    0.0065    0.0065    0.0066    0.0066
  Columns 655 through 660
    0.0066    0.0066    0.0066    0.0066    0.0066    0.0066
  Columns 661 through 666
    0.0066    0.0067    0.0067    0.0067    0.0067    0.0067
  Columns 667 through 672
    0.0067    0.0067    0.0068    0.0068    0.0068    0.0068
  Columns 673 through 678
    0.0068    0.0068    0.0068    0.0068    0.0068    0.0068
  Columns 679 through 684
    0.0068    0.0068    0.0068    0.0068    0.0068    0.0068
  Columns 685 through 690
    0.0069    0.0069    0.0069    0.0069    0.0069    0.0069
  Columns 691 through 696
...
2
Pass
 
%%
x = [1 5 4 3 8 7 3];
y_correct = 0;
assert(isequal(sortok(x),y_correct))
y =
     1     3     3     4     5     7     8
yn =
     0