The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 MATRIX errechnen
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

serga2112

Germany
Posts

Posted - 03/24/2005 :  07:35:04 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin):
Operating System:

Liebe Freunde,

ich habe ein Problemm. Habe eine Tarix in ORIGIN 20x1340. Ich muus alle Zahle in jeder Spalte dieser Matrix zusammenaddieren und in einer 21-er Zeile abbilden, so, dass ich am Ende eine matrix 21x1340 habe. Bitte, helfen sie mir, das ORIGIN C - Programm muss nicht gross sein .

Danke.

easwar

USA
1965 Posts

Posted - 03/24/2005 :  12:04:27 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello,

I translated your text from German to English using:
http://world.altavista.com/
and from what I read from the translation, you want the following:

Take a matrix that is (m rows x n cols) and make it a matrix with (m rows x n+1 cols) where the last col has the sum of cells in each row.

If this is what you want, here is code to do that.

Otherwise, please post again, and if possible, in English.

Easwar
OriginLab


void matrix_add_sum_column(string strMat)
{
// Declare matrix object with specified name and check validity
// Note: It is assumed here that the matrix is of type double
Matrix Mat(strMat);
if( !Mat )
{
printf("Invalid matrix: %s\n", strMat);
return;
}

// Create an new matrix and copy data from Original matrix;
matrix mat;
mat = Mat;

// Transpose new matrix, do sum and store in vector
// (Need to transpose because only SumColums method available now
// and no SumRows)
mat.Transpose();
vector vecSum;
mat.SumColumns(vecSum);

// Increase dimension of original matrix by one column,
// keeping orignal data where it is
int nRows, nCols;
nRows = Mat.GetNumRows();
nCols = Mat.GetNumCols();
Mat.SetSize(nRows, nCols + 1, TRUE);

// Copy summed vector to last column
Mat.SetColumn(vecSum, nCols);
}


Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000