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
 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Fit results at end of column

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
thiago.maf Posted - 09/05/2011 : 6:30:34 PM
Origin 8.0
Operating System: Windows 7

Hello, how are you?

I have a column of data and I want - set of n lines at a time. That is, I want to do multiple fittings in a column and write a new single column with all the results together.

Is there any way to concatenate the result of these various fittings in a new column?
5   L A T E S T    R E P L I E S    (Newest First)
Penn Posted - 09/08/2011 : 11:05:34 PM
Hi,

How about use the dataset variable?

For example, I suppose the source data are in column A and B for X and Y respectively, and column C and D for the X and Y of the linear fit results respectively. And the source data contain 30 rows. Then you can try the following script.

n = 5;  // fit 5 sub datasets
dataset dsox;  // dataset for output x
dataset dsoy;  // dataset for output y
dsox.setsize(30);  // set size
dsoy.setsize(30);  // set size

// start linear fits loop
for (jj=1; jj<=n; jj++) {
	nr1 = jj*5;
	nr2 = (jj+1)*5;
	
	range rix = [book1]sheet1!col(a)[$(nr1):$(nr2)]; // input column X, row 10-15
	range riy = [book1]sheet1!col(b)[$(nr1):$(nr2)]; // input column Y, row 10-15
	
	// dataset for linear fit results
	dataset dsoxTmp;  
	dataset dsoyTmp;
	fitlr iy:=(rix, riy) oy:=(dsoxTmp, dsoyTmp); // linear fit
	
	// put the linear fit results to output dataset
	for(ii=nr1, kk=1; ii<=nr2; ii++, kk++) {
		dsox[ii] = dsoxTmp[kk];
		dsoy[ii] = dsoyTmp[kk];
	}
}

// output dataset to output column
range rox = [book1]sheet1!col(c);
range roy = [book1]sheet1!col(d);
rox = dsox;
roy = dsoy;


Penn
thiago.maf Posted - 09/08/2011 : 08:19:41 AM
Hi Penn.... we are almost there...
Below is what I have in mind..... but this code will not work, because fitnr will overwrite the results in every loop.

for (jj=1; jj<=n; jj++) {
nr1 = jj*5;
nr2 = (jj+1)*5;

range rix = [book1]sheet1!col(a)[nr1:nr2]; // input column X, row 10-15
range riy = [book1]sheet1!col(b)[nr1:nr2]; // input column Y, row 10-15
range rox = [book1]sheet1!col(c)[nr1:nr2]; // output column X, row 10-15
range roy = [book1]sheet1!col(d)[nr1:nr2]; // output column Y, row 10-15
fitlr iy:=(rix, riy) oy:=(rox, roy); // linear fit
}
Penn Posted - 09/07/2011 : 01:42:46 AM
Hi,

If I have gotten what you mean, you can use the range as I mentioned before. For example:

range rix = [book1]sheet1!col(a)[10:15];  // input column X, row 10-15
range riy = [book1]sheet1!col(b)[10:15];  // input column Y, row 10-15
range rox = [book1]sheet1!col(c)[10:15];  // output column X, row 10-15
range roy = [book1]sheet1!col(d)[10:15];  // output column Y, row 10-15
fitlr iy:=(rix, riy) oy:=(rox, roy);  // linear fit


Penn
thiago.maf Posted - 09/06/2011 : 08:27:04 AM
Hi Penn, thanks

I have no problem to perform all fits. My real problem is to maintain the X index in the new column.

For example we can think about a fit between rows 10 and 15. I want the results in rows 10:15 not 1:5.... after that we have to think that I have a lots of linear fittings to work.

Is it more clearer?
Penn Posted - 09/06/2011 : 05:31:33 AM
Hi,

You can refer to this page on how to perform non-linear fitting in LabTalk. And some examples are available here. If you want the subset of a column, you can define a range.

Penn

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000