Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 837
Default Multiplying matrices in VBA

Why are you reinventing the wheel? LINEST does this.
http://www.stfx.ca/people/bliengme/E...Polynomial.htm

Depending on where your data lives, you can use one of the following
approaches from VBA
http://www.google.com/groups?selm=VA...37cab0%40t8000
http://www.google.com/groups?selm=ue...GP10.phx.gb l

These approaches can be adapted to MMULT and MMINVERSE if you really
want to do it manually.

Jerry

Mark Schreiber wrote:

I am trying to write a VBA User-defined function to develop a


quadratic curve-fit formula. It can be done on the spreadsheet


itself by creating a 3x3 square array of {X, X^2, X^3 ...} terms, and


a 3x1 vector array of {Y, XY, X^2Y} terms, then using the spreadsheet


function {=MMULT(MINVERSE(X_SquareArray),XY_VectorArray)}. This will


yield the coefficients for a quadratic polynomial y=b0 + b1*x +


b2*x^2. However, I have a number of datasets containing (X,Y)


ordered pairs, and don't want to devote a lot of spreadsheet space to


creating these arrays. Instead, I want to do all the matrix


multiplication down to obtaining the coefficients within the


user-defined function. Then the final step will be to set the


function value equal to the polynomial equation, using an input value


for x. Does anyone know how to do this trick?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 837
Default Multiplying matrices in VBA

You're welcome. Help for LINEST has mislead many a user into
undestimating its capabilities.

You can use TRANSPOSE(LINEST()) to get the coefficients in a column. sas

Jerry

Mark Schreiber wrote:

Jerry,
Thanks for the tip. I did not realize you could use LINEST to get the


coefficients for a polynomial by writing the formula using an array of


exponents {=LINEST(y's, x's^{1,2,3})}. I thought it was strictly a


linear regression tool. Not trying to reinvent the wheel, just do


something with a little finesse. Along the way, I did discover that


you can't put the output array of coefficients from LINEST into a


column; they have to be entered into a row since they are just the


first row of the more complete statistical results array. Thanks for


your excellent help.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Comparing two matrices [email protected] Excel Discussion (Misc queries) 1 May 1st 07 02:20 PM
inverse matrices Chey Excel Discussion (Misc queries) 6 January 31st 07 12:14 AM
matrices Eiman Excel Discussion (Misc queries) 0 December 9th 05 11:01 PM
Combining certain matrices [email protected] Excel Discussion (Misc queries) 1 January 8th 05 12:06 AM
transpose matrices Sander Lablans Excel Programming 4 August 4th 03 04:20 PM


All times are GMT +1. The time now is 02:38 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"