Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

MATLAB Program is Very Slow

  1. Jun 29, 2013 #1
    Hello,

    I have a MATLAB code that contains a lot of for loops, and hence it is very slow, and takes hours and hours to get just initial results, which is very inefficient. I know writing the program in terms of vectors will fasten the process, however, I do not know how to write my program that way, and I hope one of you guys will help me.

    Basically, I need to find four matrices [tex]\Phi^{(i,j)}[/tex] for i,j=1,2, where each matrix is of size N-by-N. The entries are given by:

    [tex][\Phi^{(i,j)}]_{k,m}=C_i^*(f_k)C_j(f_m)\exp\left(j\pi\vartheta_{k,m}^{(i,j)}\right)sinc\left(\vartheta_{k,m}^{(i,j)}\right)[/tex]

    where

    [tex]\vartheta_{k,m}^{(i,j)}=f_ma_i-f_ka_j+\frac{m-k}{T},\,\,\,k,m=0,1,\ldots,N-1[/tex]

    How can I do that in vector form, with the least number of for loops?

    Thanks in advance
     
  2. jcsd
  3. Jun 29, 2013 #2

    SteamKing

    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper

    How big does N get?

    What are f, C, and C*?
     
    Last edited: Jun 29, 2013
  4. Jun 29, 2013 #3
    It goes as large as 1024.
     
  5. Jun 29, 2013 #4

    SteamKing

    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper

    What are f, C,and C*?
     
  6. Jun 29, 2013 #5
    It is enough I guess if you consider f as a vector of size N-by-1. So, C is also a vector of size N-by-1. The * means complex conjugation. Also consider a1 and a2 as any numbers, it doesn't matter.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: MATLAB Program is Very Slow
  1. Matlab programming (Replies: 0)

  2. Programming in Matlab (Replies: 4)

Loading...