|
-
Apr 16th, 2001, 11:47 AM
#1
I remember some of us had posted about MathCAD, so here's a question.
Starting from a set of given data (about six scalars), I'd like to perform some calculations and automatically populate a matrix.
The matrix is for my previous post "polynomial curve fit" that I had intended to do with a programming language, but now I'd like to try it in MathCAD.
When I "perform some calculations", I'll have 50 data points for which I'd like to compute the polynomial that fits them.
So given (x0,y0), (x1,y1), ... (x49,y49), I want to populate a 50x51 matrix to look like this:
1 x0 x0^2 x0^3 ... x0^49 y0
1 x1 x1^2 x1^3 ... x1^49 y1
...
1 x49 x49^2 x49^3 ... x49^49 y49
So I'll need to compute the columns that correspond to higher powers (i.e. ^2, ^3, ..., ^49) and enter them into a 50x51 matrix.
How can this be done automatically? The only manual interaction I want is to enter the six initial scalars. I want the final result automatically from MathCAD.
1) I was thinking of some kind of loop (an "until" loop?) to write the columns to a file for each power.
2) Then read in the matrix from the file (but I think this will need to be transposed due to the order it was written?)
3) Transpose this 51x50 matrix into a 50x51 matrix?
4) Use MathCAD's ability to solve the matrix for the solution vector.
Heck, I'm assuming MAthCAD can do step 4 and I just read about file input/output. I'm using version 4.0, believe it or not.
Will this technique work?
Do you have a better idea?
Maybe there is an easier way for MathCAD to give me the polynomial without the steps I've added.
Thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|