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
 ocmath_adjave_smooth function
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

newuser_ca

70 Posts

Posted - 06/29/2012 :  2:02:28 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
OriginPro 8.6 in Win7.

I am using ocmath_adjave_smooth() function to smooth data in Origin C. But the result turned out to be different from what I got from the worksheet(from menu Analysis -> Signal Processing -> Smoothing, choose "Adjacent-Averaging", and "10" for points of window).

Here are the Origin C codes:
Column col(wks, 1);
vector<double>& vecValue = col.GetDataObject();
vector vecValueSmooth;
vecValueSmooth.SetSize(vecValue.GetSize());
ocmath_adjave_smooth(vecValue, vecValueSmooth, vecValue.GetSize(),5);


Please see the attached pictures for my worksheet and the results from Origin C. what is wrong wich my codes?
Thanks.



Here is the result from Origin C:

Sophy

China
Posts

Posted - 07/02/2012 :  12:32:29 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

Thanks for reporting this issue, and we assume this should be fixed in Origin 9.0.

Notes, before, we assume user should never get a object reference from column object and pass it directly to another function as double pointer, as in Origin C compiler, reference and double pointer are stored in different structure in memory, so such kind of that cast is problematic, and in 8.6, you can modify your code to make it work like the following:

Column col(wks, 1);
vectorbase& vb = col.GetDataObject();
vector vecValue = vb; //make a temp vector, never use reference of column object data and cast to double* directly
vector vecValueSmooth;
vecValueSmooth.SetSize(vecValue.GetSize());
ocmath_adjave_smooth(vecValue, vecValueSmooth, vecValue.GetSize(),5);


Hope it will help, thanks.

Edited by - Sophy on 07/02/2012 12:33:08 AM
Go to Top of Page

newuser_ca

70 Posts

Posted - 07/03/2012 :  10:47:09 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
It worked.

Thanks a lot!
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