the meaning of colon in Matlab

3 views (last 30 days)
Yun
Yun on 11 Aug 2012
Hello everyone,
I cannot understand the code below. Could you please be kind and help me?
fps = 1/8;
% Change to folder with images
cd('C:\Users\ZZHUI\Desktop\Bmp_DICOM\unnamed_2')
all_files = dir('*.dcm');
for i = 1:size(all_files,1)
info = dicominfo(all_files(i).name);
imagematrix(i,:,:) = dicomread(info);
DICOMimage(:,:) = imagematrix(i,:,:);
I cannot get the meaning of imagematrix(i,:,:) , and DICOMimage(:,:) = imagematrix(i,:,:)
Thanks!
Yang

Answers (2)

Image Analyst
Image Analyst on 11 Aug 2012
It means "all of that dimension", so A(:, 5) means all rows in column 5, and imagematrix(i, :, :) means the x dimension (if that's what it means) is "i" and you're taking all y and all z for which x == i. In other words, you're taking a y-z slice in the 3D image along the plane x=i.

Azzi Abdelmalek
Azzi Abdelmalek on 11 Aug 2012
imagematrix(i,:,:) is 3D matrix
suppose you have 4 matrix 3x2 we can save all 4 matrix in one variable M
M(:,:,1) is the first matrix 3x2,
M(:,:,2) is the second matrix 3x2
...
M(:,:,4) is the fourth matrix 3x2
the first ":" means all line
the second ":" means all columns
the third ":" means all matrix

Community Treasure Hunt

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

Start Hunting!