Solving MATLAB Problems with R1, RF, R2 and w Variables

  • Context: MATLAB 
  • Thread starter Thread starter zhaniko93
  • Start date Start date
  • Tags Tags
    Matlab Rf Variables
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
5 replies · 3K views
zhaniko93
Messages
13
Reaction score
0
I have such MATLAB problem: I create variables R1 RF R2 and w so:
Code:
Code:
syms RF R1 R2 w
then I write expression:
Code:
Code:
3*R1*w*(RF + 200)/((R2*w*29*i + 3)*(3*R1*w - 2*i))
which gives:
Code:
Code:
(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:
real(ans)
it gives:
Code:
Code:
3*real((R1*w*(RF + 200))/((3*R1*w - 2*sqrt(-1))*(R2*w*29*sqrt(-1) + 3)))
can anyone please help me??
 
Physics news on Phys.org
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.
 
I want MATLAB to write my expression of type a/(b+ci)(d+li) to a+bi form and then give b
 
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
 
It didn't help :((((
 
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))))