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

MATLAB problem

  1. Jun 4, 2012 #1
    I have such matlab problem: I create variables R1 RF R2 and w so:
    Code:
    Code (Text):
    syms RF R1 R2 w
    then I write expression:
    Code:
    Code (Text):
    3*R1*w*(RF + 200)/((R2*w*29*i + 3)*(3*R1*w - 2*i))
    which gives:
    Code:
    Code (Text):
    (3*R1*w*(RF + 200))/((3*R1*w - 2*sqrt(-1))*(R2*w*29*sqrt(-1) + 3))
    why sqrt(-1) and not i???? furthermore? if I want real part of the expression and write:
    Code:
    Code (Text):
    real(ans)
    it gives:
    Code:
    Code (Text):
    3*real((R1*w*(RF + 200))/((3*R1*w - 2*sqrt(-1))*(R2*w*29*sqrt(-1) + 3)))
    can anyone please help me??
     
  2. jcsd
  3. Jun 4, 2012 #2
    what is it that you don't like about what matlab is doing? Please expand.

    What's wrong with sqrt(-1) instead of "i" ... what did you mean with "i"? is it an integer loop variable ? if so, you have not read the basic assumption of matlab i= sqrt(-1)

    Also, what's wrong with real(3*complex_number) = 3*real(complex_number) ? I don't see any thing wrong with that.

    Remember, it is not a human manipulating your code, it is a computer program that programatically follows certain steps and optimizations to ensure an answer.
     
  4. Jun 5, 2012 #3
    I want matlab to write my expression of type a/(b+ci)(d+li) to a+bi form and then give b
     
  5. Jun 5, 2012 #4
    Have you tried >>vpa(your expression) or >>simplify(collect(your expression,i))? The first will condense all your constants if they're given numerically, whereas the second will organize your symbolic expressions into coefficients of 1 and i (i.e. a and b). Hope that helps.

    Rebekah
     
  6. Jun 7, 2012 #5
    It didn't help :((((
     
  7. Jun 7, 2012 #6
    Here's what worked for me just now on matlab 7.14:

    >>a=real(collect(3*R1*w*(RF + 200)/((R2*w*29*i + 3)*(3*R1*w - 2*i))))
    >>b=imag(collect(3*R1*w*(RF + 200)/((R2*w*29*i + 3)*(3*R1*w - 2*i))))
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: MATLAB problem
  1. Matlab problem (Replies: 1)

  2. Matlab problem (Replies: 4)

  3. Matlab problem (Replies: 0)

  4. MATLAB problem (Replies: 1)

Loading...