Search code examples
matlabsymbolic-math

Matlab Syntax for Symbolic Solving


I have a symbolic equation equation like

i = 1:n (i=1...n) it takes random values.

G_i = B_i + C_i * D_i and I have B_i, G_i C_i and D_i equaling to some constraints.

I have to simplify a such equation through matlab.

I used 'syms' to define each symbol but I don't know how to define that 'i' indices.

Also, my second question is if I want to change it to summation format (symsum) where i=1...n how can I write the code for to simplify given some constraints. Any example can be useful for me to understand.


Solution

  • What you want to do is create an array of symbolic values: Matlab docs show how to do this for A, I'll leave it up to you to do the rest.

    A = sym('A',dim)
    

    Then you could do something like:

    G(i)=b(i)+c(i)*d(i)