Is there any way to vectorize this code...

Discussion in 'MATLAB' started by sbm, Jul 18, 2008.

  1. sbm

    sbm Guest

    Hi

    Can anyone help me in vectorizing this code....

    M & N are the boundaries.....


    for theta = 0:pi/180:2*pi;
    x = cent_x + radius*sin(theta);
    y = cent_y - radius*cos(theta);
    if round(x) < N && round(x) > 1 && round(y) < M && round(y)>1
    temp(round(x),round(y)) = 1;
    end
    end


    Thanks
     
    sbm, Jul 18, 2008
    #1
    1. Advertisements

  2. sbm

    dpb Guest

    ....

    Look up "logical indexing" in documentation...

    --
     
    dpb, Jul 18, 2008
    #2
    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.