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
 LabTalk Forum
 Fit results at end of column
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

thiago.maf

22 Posts

Posted - 09/05/2011 :  6:30:34 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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?

Penn

China
644 Posts

Posted - 09/06/2011 :  05:31:33 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

thiago.maf

22 Posts

Posted - 09/06/2011 :  08:27:04 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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?
Go to Top of Page

Penn

China
644 Posts

Posted - 09/07/2011 :  01:42:46 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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

Edited by - Penn on 09/07/2011 01:46:06 AM
Go to Top of Page

thiago.maf

22 Posts

Posted - 09/08/2011 :  08:19:41 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
}
Go to Top of Page

Penn

China
644 Posts

Posted - 09/08/2011 :  11:05:34 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
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