help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Przemek Klosowski
Subject: Re: How to get a trend surface function from raw data
Date: Fri, 5 Jan 2018 12:33:25 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0

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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]