Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
symbolic equation coefficients

Subject: symbolic equation coefficients

From: Elliot

Date: 20 Jun, 2011 15:33:04

Message: 1 of 3

PROBLEM BACKGROUND
Im writing a code for the Finite Volume method and at some point I have a set of equations with symbolic terms and their coefficients, for each cluster. A cluster being defined as the group of cells surrounding a given vertex.

i.e. 2a + 3b + 4c + 5d etc.

The set of equations is stored in a vector, i.e. call the equation above 'A' the vector,
[A
 B
 C
 D]; etc

represent the system of equations for each cluster.

I am also working in unstructured meshes, therefore, the size of the cluster (number of cells attached to the vertex) can technically be any number. So the vector containing the set of equations can be any length depending on the cluster size. The number of symbolic terms and coefficients per equation is equal to the length of the vector containing the set of equations.

AIM
I need to extract the coefficients from each line and store them in a global matrix.

ISSUES
When using 'coeffs', the coefficients are stored in some order I cannot determine, i.e. they are not stored corresponding to how they are found in the equation (a,b,c,d), they are not stored in numerical order. So using 'coeffs' does gove me the correct coefficients, however, their connectivity to the global matrix is lost because I dont know how 'coeffs' orders its results.

I have tried looking for each symbolic term's coefficient ,using 'coeffs(A,a)' for example, but MATLab doesnt recognise the symbolic term 'a' in the function 'coeffs' even though it is defined previously as a symbolic term.

Thanks for any help offered

Subject: symbolic equation coefficients

From: Steven_Lord

Date: 20 Jun, 2011 17:26:27

Message: 2 of 3



"Elliot " <436277@swansea.ac.uk> wrote in message
news:itnp7g$pj9$1@newscl01ah.mathworks.com...

*snip*

> When using 'coeffs', the coefficients are stored in some order I cannot
> determine, i.e. they are not stored corresponding to how they are found in
> the equation (a,b,c,d), they are not stored in numerical order. So using
> 'coeffs' does gove me the correct coefficients, however, their
> connectivity to the global matrix is lost because I dont know how 'coeffs'
> orders its results.

Use the two output form of COEFFS.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: symbolic equation coefficients

From: Roger Stafford

Date: 20 Jun, 2011 17:28:04

Message: 3 of 3

"Elliot" wrote in message <itnp7g$pj9$1@newscl01ah.mathworks.com>...
> When using 'coeffs', the coefficients are stored in some order I cannot determine, i.e. they are not stored corresponding to how they are found in the equation (a,b,c,d), they are not stored in numerical order. So using 'coeffs' does gove me the correct coefficients, however, their connectivity to the global matrix is lost because I dont know how 'coeffs' orders its results.
>
> I have tried looking for each symbolic term's coefficient ,using 'coeffs(A,a)' for example, but MATLab doesnt recognise the symbolic term 'a' in the function 'coeffs' even though it is defined previously as a symbolic term.
>
> Thanks for any help offered
- - - - - - - - - - -
  I didn't completely understand the description of your problem. The 'coeffs' function is supposed to apply to polynomials.

  The documentation for 'coeffs' says, "[C, T] = coeffs(p, x) returns a list of the coefficients and a list of the terms of p. There is a one-to-one correspondence between the coefficients and the terms of p." Is that of any use to you?

Roger Stafford

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us