Results 1 to 5 of 5

Math Help - i need your help .......Matlab

  1. #1
    Newbie
    Joined
    Oct 2008
    Posts
    13

    i need your help .......Matlab

    hey guys
    i have a problem with Matlab i could not figure it out
    i constructed a Matlab code that shows me all possible values of k and w relating to this equation
    w=exp(2*pi*j*k/5) where k=0,1,2 ,3 ,4
    so the expected result would be
    k w
    0 1
    1 0.309 + j 0.951
    2 -0.809 + j 0.5877
    3 -0.809 - j 0.5877
    4 0.309 - j 0.951

    but the problems is my code does not show me the imaginary part , it shows me only the real part of W as shown in the attached file
    i need your help guys
    thank you for your cooperations
    Attached Thumbnails Attached Thumbnails i need your help .......Matlab-matlab-help.jpg  
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by Zamorano View Post
    hey guys
    i have a problem with Matlab i could not figure it out
    i constructed a Matlab code that shows me all possible values of k and w relating to this equation
    w=exp(2*pi*j*k/5) where k=0,1,2 ,3 ,4
    so the expected result would be
    k w
    0 1
    1 0.309 + j 0.951
    2 -0.809 + j 0.5877
    3 -0.809 - j 0.5877
    4 0.309 - j 0.951

    but the problems is my code does not show me the imaginary part , it shows me only the real part of W as shown in the attached file
    i need your help guys
    thank you for your cooperations
    Not the only thing wrong, but you are trying to print complex numbers using a real format. Try something like:

    Code:
     
    'k           re(w)           im(w)'
     
    for k=0:4
       w=exp(2*pi*k*j/5);
       printf('%4.2f %14.6f %14.6f \n',k,real(w),imag(w));
    end
    CB
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Oct 2008
    Posts
    13
    thank you CaptinBlack
    but this is not the required
    i want a Matlab code shows me both the real and imaginary parts as this form : w=a+jb
    your code shows this form : w = a (imag) b

    if you can give me an imaginary format for this program i will appreciated

    thank you for ur cooperation
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by Zamorano View Post
    thank you CaptinBlack
    but this is not the required
    i want a Matlab code shows me both the real and imaginary parts as this form : w=a+jb
    your code shows this form : w = a (imag) b

    if you can give me an imaginary format for this program i will appreciated

    thank you for ur cooperation
    Well Matlab (and C) do not support a format code for complex numbers so you will have to work something out for yourself if you wish to use fprintf or printf. Possibly using num2str to convert the complex numbers to strings for printing, or something like:

    printf('%12.1f %+12.2fj \n',real(x),imag(x))

    or:

    printf('%s \n',num2str(x))

    CB
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Newbie
    Joined
    Oct 2008
    Posts
    13
    Thanks CB
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Matlab help
    Posted in the Math Software Forum
    Replies: 1
    Last Post: February 11th 2010, 03:59 AM
  2. Matlab FFT Help
    Posted in the Math Software Forum
    Replies: 0
    Last Post: June 3rd 2009, 01:48 PM
  3. help about ODE in matlab
    Posted in the Math Software Forum
    Replies: 1
    Last Post: May 31st 2009, 04:10 AM
  4. Matlab Please help me
    Posted in the Math Software Forum
    Replies: 8
    Last Post: November 10th 2008, 05:40 PM
  5. Matlab
    Posted in the Calculus Forum
    Replies: 3
    Last Post: August 20th 2008, 11:39 PM

Search Tags


/mathhelpforum @mathhelpforum