1. Since these are cell arrays, learn to use cellfun. This is a tool that can apply some function to each element of a cell array.

2. Can you write a function that will compute the maximum of a vector? (Hint: you already have one. Give Max a call, and see if he knows the name of that function.)

3. Do you know how to index a cell array, creating a new cell array, so you have extracted all but the first into a new temporary cell array?

4. Can you then compute the maximum of every element of a cell array? (See steps 1 and 2.) I the result of this operation a vector?

5. Can you sort a vector in descending order? If not, then read the help for sort. What is the second output argument from sort? If you don't know how to use sort, then read the help. Read what "doc sort" tells you! Are there examples in there? Look at the examples.

6. Can you use the set of indices, the sort tags that came from the second output of sort, to then sort the cell array from step 3?

7. Finally, stuff the sorted array back into the first, replacing elements 2:end.

I'm sorry if it seems I have acted as if you have not a clue how to use MATLAB, but from your question, you have not bothered to try reading the help for the tools you want to use. And you clearly are not comfortable with cell arrays.

Break large problems into small problems. Solve each sub-problem, if necessary doing the work to learn what you need. This often means reading the help for tools. Here, those tools might be cellfun, max, sort. You also need to learn to index arrays. At every step, dump what you did onto the command window. Did it do what you expected? Try several cases, until you are sure you understand the process. This is how you will learn. TRY IT. Make an effort. If you get stuck, then ask again. If you want, as a comment on my answer. Show what you tried. I'll give you more help if you show an effort.

I'll even get you started.

>> D = {[0 0 1 2 3 ] , [0 0 4 0 0 ], [0 5 6 0 ], [4 0 ]}

D =

1×4 cell array

{1×5 double} {1×5 double} {1×4 double} {1×2 double}

>> D{:}

ans =

0 0 1 2 3

ans =

0 0 4 0 0

ans =

0 5 6 0

ans =

4 0

The second line I wrote extracts the elements of the cell array, putting them into what is called a comma separated list. It is a nice way to display all elements of a cell array in the command window. It can also be used to pass them as separate arguments into a function, though you will not need that capability at all today.

You should try learn to use MATLAB. For example, can you find a way to compute the sum of every cell in that array, returning the result as a simple vector, thus not a cell array? Get your hands dirty. At least your fingertips.

I am serious here. When you cannot solve a problem, you look to see if you can do something to get closer to your goal. Can you find a tool that does what you need? Break the big programming elephant into byte sized chunks. Eat it one byte at a time.