How to get a trend surface function from raw data

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to get a trend surface function from raw data

alessio31183
Dear all,
I'm quite new in octave env and this is the first post for me.

Basically I have this issue.
I've designed a new sensor where, unlikely, a temperature change makes a
change in reading.
Of course I need to compensate this unwanted behavior.

I did some tests to make this table that  is the error in measurement in
[°/°C]
                   
Angle °         5°C        25°C   50°C        
                       
181.10 0.0184 0.0000 -0.0167
219.56 0.0041 0.0000 -0.0010
263.90 -0.0153 0.0000 0.0193
5.45       -0.0151 0.0000 0.0173
48.17 0.0028 0.0000 -0.0042
77.03 0.0141 0.0000 -0.0179
124.98 0.0229 0.0000 -0.0252
165.05 0.0155 0.0000 -0.0275

Now I need to make the surface trend function and to implement it in
firmware in order to compensate the wrong value.

Usually the temperature effect is just function of temperature, so a simple
trend line (linear or polynomial)

Not in this case where the error is temperature and angle function, so a
surface function.

What I ask you is a method to get the function in octave (commands and so
on).

Thanks in advance




--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: How to get a trend surface function from raw data

Przemek Klosowski-7
On 01/05/2018 10:43 AM, alessio31183 wrote:
I've designed a new sensor where, unlikely, a temperature change makes a
change in reading. Of course I need to compensate this unwanted behavior.

I did some tests to make this table that  is the error in measurement in
[°/°C]	
	            
Angle °         5°C        25°C	   50°C	        	
			
181.10	0.0184	0.0000	-0.0167
219.56	0.0041	0.0000	-0.0010
263.90	-0.0153	0.0000	0.0193
5.45	       -0.0151	0.0000	0.0173
48.17	0.0028	0.0000	-0.0042
77.03	0.0141	0.0000	-0.0179
124.98	0.0229	0.0000	-0.0252
165.05	0.0155	0.0000	-0.0275

It's a nice exercise showing Octave's practical usefulness. First, you want to see the data and display it:
 a=sortrows([
 181.10  0.0184  0.0000  -0.0167
 219.56  0.0041  0.0000  -0.0010
 263.90  -0.0153 0.0000  0.0193
 5.45    -0.0151 0.0000  0.0173
 48.17   0.0028  0.0000  -0.0042
 77.03   0.0141  0.0000  -0.0179
 124.98  0.0229  0.0000  -0.0252
 165.05  0.0155  0.0000  -0.0275
 ],1)
[ang,temp]=meshgrid(a(:,1),[5,25,50])
mesh(ang,temp,a(:,2:end)')

So, if you had a model for the error, you could fit it here, but since you don't mention anything, we'll eyeball it.
The error surface is almost-but-not-quite linear in temperature, but there is a strange kink in the error  between 150 and 200 deg at  T=5, so the question is how accurate is your error data? I think it's +-10% so a reasonable error approximation could be  .025*sin((ang-40).*pi./180).*(1-(temp-5)/22.5)

 hold off; mesh(ang,temp,a(:,2:end)'); hold on ; mesh(ang,temp,arrayfun(@(ang,temp) .025*sin((ang-40).*pi./180).*(1-(temp-5)/22.5),ang,temp))

If you get better error data, you could start fitting this (or some other) ad-hoc 2-d function to your data, using e.g. leasqr() from the optim package.


_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave