Colum

Discussion in 'MATLAB' started by Victoria Emberle, Dec 14, 2010.

  1. Hello,

    I want a matrix where I get for the first column(1,2,3,4,5,6,7,8,9,....n) and second column is NumbCTImgs.

    here is my code
    CT_ID=zeros(NumbCTImgs,1)
    for i= 1:NumbCTImgs
    CT_ID(i)=Imgs.CT(i).Tags.PatientID;

    right now I get a matrix (261X1)
    4
    5
    6
    7

    I want a matrix

    1 4
    2 5
    3 6
    4 7

    How can I change my code to accomplish this?
     
    Victoria Emberle, Dec 14, 2010
    #1
    1. Advertisements

  2. Victoria Emberle

    ImageAnalyst Guest

    How about something like this
    n = 161;
    CT_ID = zeros(n,2);

    CT_ID:), 1) = 1 : n;

    for k = 1:NumbCTImgs
    CT_ID(k, 2)=Imgs.CT(k).Tags.PatientID;
     
    ImageAnalyst, Dec 14, 2010
    #2
    1. Advertisements

  3. Q = Imgs.CT.Tags;
    CT_ID = [(1:length(Q)).', vertcat(Q.PatientID)];

    It could probably be done in one line, but obscurely.
     
    Walter Roberson, Dec 14, 2010
    #3
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.