Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Defining a MATLAB code for a series expansion

Status
Not open for further replies.

rakue

Newbie level 5
Newbie level 5
Joined
Oct 27, 2012
Messages
10
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,362
Hi guys, I'm relatively new to the matlab designing process (i.e. making good use of it's vector-based system) I need help producing a matlab code for the following equation:

equation.jpg


is there a way to be able to produce it using matrices without the tedious use of for and while loops? or is there no other way?

thank you very much for any help that guys can extend.
 

That equation doesn't seem to be following a pattern so it'll be easier to input by hand.
 

That equation doesn't seem to be following a pattern so it'll be easier to input by hand.

Hi thanks for your reply. actually there is a pattern. It's basically a combination of the powers of T_RF, T_LO and T_IF from 0 to 2.

I'm hoping I could come up with a "generalized" code so that if I decide to add more T variables and increase the power up to say, 6 or 8.
 

Okay I realized that a possible approach would be to use permutations like say for my 3 variables x,y,z I want to make a permutation of their powers from 0 to 2 such that the output would look like this

0 0 0
0 0 1
0 1 0
1 0 0
0 1 1
1 1 0
1 0 1
1 1 1
.
.
.
2 2 2


and then using the output for each row from the matrix produced, assign that element to my variables.

will that work? if so, can anyone tell me how? thank you~
 

Hi thanks for your reply. actually there is a pattern. It's basically a combination of the powers of T_RF, T_LO and T_IF from 0 to 2.

I'm hoping I could come up with a "generalized" code so that if I decide to add more T variables and increase the power up to say, 6 or 8.

So, what's the pattern here? The pattern must match certain rules if you'll write a compact equation and did you notice the multiplier count for each term is not constant? The constants (I'm guessing they are constants) from m8 to m19 have only 2 variables in the multiplication while the last 8 have 3. So again what's the pattern here? I think the best you can do is to divide the total formula into 4 parts each for the number of variables in each term (0, 1, 2, 3).
 

Hi rakue,

Please analyse this. I use 3-dimensional arrays:


T1 = [ 1, T_RF, T_RF*T_RF ];
T2 = [ 1, T_LO, T_LO*T_LO ];

T12 = T1.' * T2;

T123 = cat(3, T12, T12*T_IF, T12*T_IF*T_IF);

% Here, M must be a 3*3*3 array containing the 27 "m" coefficients

mc = sum(sum(sum(M .* T123)))



Regards

Z
 

In order to see the structure of the resulting array T123, it is possible to generate it as a symbolic variable in the following way. Type these commands:


syms T_RF T_LO T_IF

T1 = [ 1, T_RF, T_RF*T_RF ];
T2 = [ 1, T_LO, T_LO*T_LO ];

T12 = T1.' * T2;

T123 = cat(3, T12, T12*T_IF, T12*T_IF*T_IF)



Then T123 is printed like this:

123:),:,1) =

[ 1, T_LO, T_LO^2]
[ T_RF, T_RF*T_LO, T_RF*T_LO^2]
[ T_RF^2, T_RF^2*T_LO, T_RF^2*T_LO^2]


T123:),:,2) =

[ T_IF, T_IF*T_LO, T_IF*T_LO^2]
[ T_IF*T_RF, T_IF*T_RF*T_LO, T_IF*T_RF*T_LO^2]
[ T_IF*T_RF^2, T_IF*T_RF^2*T_LO, T_IF*T_RF^2*T_LO^2]


T123:),:,3) =

[ T_IF^2, T_IF^2*T_LO, T_IF^2*T_LO^2]
[ T_IF^2*T_RF, T_IF^2*T_RF*T_LO, T_IF^2*T_RF*T_LO^2]
[ T_IF^2*T_RF^2, T_IF^2*T_RF^2*T_LO, T_IF^2*T_RF^2*T_LO^2]



Regards

Z
 
  • Like
Reactions: rakue

    rakue

    Points: 2
    Helpful Answer Positive Rating
Thank you very much, Zorro. Sorry for the noob-ish question, but is it possible to use syms in my code and then eventually replace the variables with actual data from a separate file?
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top