Vincent Cheung

Vincent Cheung's Blog


« Newer Post Home Older Post »

Monday, July 19, 2004

More Matlab Tricks

Neither Anitha nor Brendan knew about this (I was coding on the fly during our last meeting).

To kill a row in a matrix in Matlab do the following:
>> a = magic(3)

a =

8 1 6
3 5 7
4 9 2

>> a(2, :) = []

a =

8 1 6
4 9 2

Works just as well for columns. You can also remove individual elements, but if you do it in a matrix, you'll end up with a vector.

I titled this "More Matlab Tricks" cuz I had two tricks to record, but forgot the second one.....doh....

2 Comments:

Anonymous said...

Hello

I was wondering how would you stalk a a 3D matrix. For example, lets say you have a matrix A=244X306X1 which represents one slice and the second matrix B=244X306X2 etc.. until :,:,20. How would you construct a 3D matrix such that final=244X306X20 where the 20 represents the same slices that is 1...20(same image or slice).
Hope that makes sense.

Thank you

Zeinab

Vince said...

You can use the cat function

Post a Comment