seprate the result from one colum to different colums

Discussion in 'MATLAB' started by eesa, Aug 12, 2010.

  1. eesa

    eesa Guest

    I have the following code but the result it returns to me in one colum but what i need iis that when the value of the loop change, i want to give me the result in different cloum
    defined x is a metrix

    for i=1:18,
    for j=i+1:19,
    p=[d y];

    Now, the above code return to me the all of the result in one colum and i want to get the result into different colums.

    Thanks in Adance
    eesa, Aug 12, 2010
    1. Advertisements

  2. eesa

    eesa Guest

    please help me on that i tried several ways but it does not work.
    eesa, Aug 12, 2010
    1. Advertisements

  3. eesa

    Steven_Lord Guest

    Every iteration through the loop, you're overwriting d, y, p, and f.
    Instead of overwriting, preallocate them to be the correct size BEFORE the
    loop and fill them in using indexed assignment inside the loop. As a
    simpler example you can adapt to your program:

    x = zeros(10, 1);
    for k = 1:10
    x(k, :) = k.^2;

    [And yes, I know there's a simpler way to do that. I'm using it simply to
    demonstrate the techniques of preallocation and indexed assignment.]

    Steve Lord

    comp.soft-sys.matlab (CSSM) FAQ:
    To contact Technical Support use the Contact Us link on
    Steven_Lord, Aug 12, 2010
    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.