Plot 3d scattered data using gnuplot - bash

Hi I just got some 3d scattered data (the data name is just data.txt) which look like the following:
0 0 0
-1.08051e-16 -1.73991e-16 -1.79157e-16
-1.02169e-15 -1.19283e-15 5.92632e-16
3.41114e-16 -1.02211e-15 3.19436e-15
-4.51742e-15 -5.18861e-15 -4.60754e-15
-2.00685e-15 -4.67813e-15 -4.86101e-15
-9.82727e-16 -2.24413e-15 -5.87927e-16
-7.74439e-16 -9.73515e-16 -1.69707e-15
4.32668e-16 2.15869e-15 -2.25004e-15
-3.74495e-15 -2.20596e-15 -7.33201e-16
-4.97941e-16 -5.45749e-16 -2.93136e-15
-2.40174e-15 -4.31022e-15 7.13531e-15
-4.58812e-15 -4.38568e-15 -9.99635e-16
-7.00716e-15 7.53852e-15 -8.484e-15
4.50028e-15 2.2255e-15 2.32808e-15
-8.57887e-15 3.09127e-15 -3.49207e-15
-2.0608e-16 -6.06078e-15 -6.07822e-16
-7.76829e-15 -1.47001e-14 -1.08924e-14
1.04016e-15 6.33122e-16 -2.11985e-15
2.33557e-15 -7.92667e-15 2.52748e-15
6.94335e-15 3.70286e-15 -1.44815e-15
.........
the 1st,2nd and 3rd column represent x,y and z axis, respectively.
I'd like to use splot command to plot these data. Can anyone kindly give some suggestions? Thanks.

Since your data is nicely formatted, you could start with
splot 'data.txt'
If you want to get fancy, you can add some options to change how it is plotted:
splot 'data.txt' with points pointtype 7
What kind of suggestions are you looking for?

Related

Line fitting python

I have these two arrays x and y (pink scatter points), and I want to fit a line as shown in the figure (blue line). However, I have not been able to find the proper fit or a proper equation. I have tried exponentials, polyfits and nothing. Maybe someone here has an idea. Original x and y data are here.
x=[50.56457351, -25.94178241, 10.20492002, -4.42553174,
-27.33151148, -29.9721279 , 36.06962759, 7.56321785,
52.94172778, 1.99279668, 70.60954309, -41.28236289,
-28.56116707, -43.98117436, 19.52197933, -13.99493533,
-35.4383463 , -44.3050207 , -3.96679614, 14.88981502]
y=[-3.39506291, 5.07105136, 21.0870528 , 17.67702032, 0.03026157,
6.45900452, -0.19873009, 7.50795551, -1.82804242, -3.65200329,
-2.93492827, -5.86174941, -2.50507783, -3.43619693, -2.66194664,
-3.59860008, -0.19628881, -2.94505151, -2.3179664 , -2.29120004]

Gnuplot: data normalization of multiple dataset in one file

Image one file with 250 datasets with varying length (2000 +-500) lines and 11 columns. Here a comprehensive small example:
file.sum:
0.00000e+00 9.51287e-09
1.15418e-04 8.51287e-09
4.16445e-04 7.51287e-09
8.53721e-04 6.51287e-09
1.42697e-03 5.51287e-09
1.70302e-03 4.51287e-09
2.27189e-03 3.51287e-09
2.54732e-03 1.51287e-09
3.11304e-03 0.51287e-09
0.00000e+00 13.28378e-09
1.15418e-04 12.28378e-09
3.19663e-04 11.28378e-09
5.78178e-04 10.28378e-09
8.67479e-04 09.28378e-09
1.20883e-03 08.28378e-09
1.58817e-03 07.28378e-09
1.75840e-03 06.28378e-09
2.21069e-03 05.28378e-09
I wanted to display every 10 datasets and normalize it to the first element. The first value to normalize is 9.51287e-09 and the second would be 13.28378e-09. Of course with this massive dataset, I can not do it manually or even split the file.
So far I got every ten'th dataset but with the normalization, I do have my problems.
#!/usr/bin/gnuplot
reset
set xrange [0:0.1]
plot for [val=1:250:10] 'file.sum' i val u 1:11 w l
Working of this example:
plot.gp:
#!/usr/bin/gnuplot
reset
set xrange [0:0.01]
plot for [val=1:2:1] 'file.sum' i val u 1:2 w l
Some hints I found in:
Gnuplot: data normalization
I guess you can write a awk script to handle this, but there may be a more gnuplot friendlier way. Any suggestions are appreciated.
Assuming you have one file with data sections each separated by two or more empty lines you can use the script below.
In gnuplot console check help pseudocolumns. column(-2) tells you in which block you are and column(0) tells you wich line of this block you are (counting starts from 0).
Define a function Normalized(n) which does the following: if you are in the first line of a subblock put the value of column(n) into the variable y0. All values of this block will now be divided by y0. Also check help ternary.
In case you want a legend for the blocks you can plot a dummy plot, actually plotting NaN (i.e. nothing) but place an entry for the key.
Code:
### normalize each block by its first value
reset session
set colorsequence classic
$Data <<EOD
0.00000e+00 9.51287e-09
1.15418e-04 8.51287e-09
4.16445e-04 7.51287e-09
8.53721e-04 6.51287e-09
1.42697e-03 5.51287e-09
1.70302e-03 4.51287e-09
2.27189e-03 3.51287e-09
2.54732e-03 1.51287e-09
3.11304e-03 0.51287e-09
0.00000e+00 13.28378e-09
1.15418e-04 12.28378e-09
3.19663e-04 11.28378e-09
5.78178e-04 10.28378e-09
8.67479e-04 09.28378e-09
1.20883e-03 08.28378e-09
1.58817e-03 07.28378e-09
1.75840e-03 06.28378e-09
2.21069e-03 05.28378e-09
EOD
Normalized(n) = column(n)/(column(0)==0 ? y0=column(n) : y0)
plot $Data u 1:(Normalized(2)):(myBlocks=column(-2)+1) w lp pt 7 lc var notitle, \
for [i=0:myBlocks-1] '' u 1:(NaN) w lp pt 7 lc i+1 ti sprintf("Block %d",i)
### end of code
Result:

Fairing data points in 3D

I have a set of data points that are supposed to define a smooth surface. X/Z are specified at intervals and Y is dependent upon Y/Z.
The location of the points is rounded to within a fixed tolerance.
If one draws a curve (e.g. spline) through an X or Z slice, the rounding causes the curves to zigzag or create steps.
For example a set of linear value forming a straight line, when rounded to an integer form a step:
1 1 2 2 3 instead of 1 1.5 2 2.5 3
What would like to do is fair the data to convert the rounded values to real values that produce smooth curves that will define a smooth surface without oscillations.
There are tools to do this on 2D. They look for oscillations in the 2d derivative. The problem this creates in my case is that fairing along an X/Y curves can unfair along an intersecting Y/X curve. I need to create something that will fair along X/Y and Y/Z at the same time.
I was wondering if there anyone knows of algorithms to do this.
Sample Data Set
1392,175.8125,378
1296,161.0625,378
1128,231.375,725.5
1152,233.625,723.8125
1176,235.875,722.125
1200,238.25,720.4375
1224,240.5,718.875
1248,242.875,717.25
1272,245.375,715.625
1296,247.75,714.125
1320,250.25,712.5625
1344,252.8125,711.125
1368,255.375,709.5625
1392,258.0625,708.0625
1416,260.75,706.625
1440,263.5,705.25
1464,266.125,703.8125
1128,100.875,0
1152,101.75,0
1176,102.6875,0
1200,103.5625,0
1224,104.3125,0
1248,105.125,0
1272,105.875,0
1296,106.625,0
1320,107.25,0
1344,107.875,0
1368,108.625,0
1392,109.1875,0
1416,109.8125,0
1440,110.4375,0
1464,111.125,0
1128,115.5,3
1152,116.75,3
1176,117.8125,3
1200,118.875,3
1224,120.0625,3
1248,121.0625,3
1272,122,3
1296,123,3
1320,124,3
1344,125,3
1368,126,3
1392,126.875,3
1416,127.875,3
1440,128.875,3
1464,129.75,3
1128,122.25,6
1152,123.4375,6
1176,124.5625,6
1200,125.75,6
1224,126.875,6
1248,128,6
1272,129.125,6
1296,130.25,6
1320,131.375,6
1344,132.4375,6
1368,133.5,6
1392,134.5625,6
1416,135.625,6
1440,136.625,6
1464,137.625,6
1128,131.375,12
1152,132.6875,12
1176,133.9375,12
1200,135.25,12
1224,136.4375,12
1248,137.6875,12
1272,138.875,12
1296,140.25,12
1320,141.3125,12
1344,142.5,12
1368,143.75,12
1392,145,12
1416,146.1875,12
1440,147.375,12
1464,148.5,12
1128,144.9375,24
1152,146.25,24
1176,147.5,24
1200,148.75,24
1224,150.1875,24
1248,151.4375,24
1272,152.75,24
1296,154.125,24
1320,155.4375,24
1344,156.75,24
1368,158,24
1392,159.25,24
1416,160.5625,24
1440,161.875,24
1464,163.125,24
1128,161.625,48
1152,162.8125,48
1176,164.1875,48
1200,165.625,48
1224,166.9375,48
1248,168.3125,48
1272,169.75,48
1296,171.25,48
1320,172.6875,48
1344,174,48
1368,175.375,48
1392,176.75,48
1416,178.1875,48
1440,179.625,48
1464,181.0625,48
1128,168.75,72
1152,170.25,72
1176,171.75,72
1200,173.25,72
1224,174.875,72
1248,176.375,72
1272,178,72
1296,179.5,72
1320,181.1875,72
1344,182.75,72
1368,184.25,72
1392,185.8125,72
1416,187.5,72
1440,189.125,72
1464,190.75,72
1128,170.1875,96
1152,171.875,96
1176,173.5,96
1200,175.25,96
1224,176.875,96
1248,178.75,96
1272,180.5,96
1296,182.25,96
1320,184,96
1344,185.75,96
1368,187.5625,96
1392,189.3125,96
1416,191.125,96
1440,193,96
1464,194.9375,96
1128,169.0625,120
1152,170.8125,120
1176,172.75,120
1200,174.625,120
1224,176.5,120
1248,178.375,120
1272,180.3125,120
1296,182.625,120
1320,184.25,120
1344,186.25,120
1368,188.125,120
1392,190.1875,120
1416,192.125,120
1440,194.25,120
1464,196.3125,120
1128,166.625,144
1152,168.625,144
1176,170.625,144
1200,172.625,144
1224,174.75,144
1248,176.75,144
1272,178.8125,144
1296,181,144
1320,183.0625,144
1344,185.25,144
1368,187.4375,144
1392,189.5,144
1416,191.75,144
1440,194,144
1464,196.3125,144
1128,163.75,168
1152,165.75,168
1176,168,168
1200,170.1875,168
1224,172.4375,168
1248,174.625,168
1272,176.75,168
1296,179.125,168
1320,181.375,168
1344,183.625,168
1368,186,168
1392,188.625,168
1416,190.75,168
1440,193.125,168
1464,195.625,168
1128,160.5625,192
1152,162.875,192
1176,165.1875,192
1200,167.5,192
1224,169.875,192
1248,172.25,192
1272,174.625,192
1296,177.0625,192
1320,179.4375,192
1344,181.9375,192
1368,184.4375,192
1392,186.875,192
1416,189.5,192
1440,192.0625,192
1464,194.6875,192
1128,157.3125,216
1152,159.8125,216
1176,162.3125,216
1200,164.8125,216
1224,167.25,216
1248,169.6875,216
1272,172.3125,216
1296,174.875,216
1320,177.3125,216
1344,179.9375,216
1368,182.625,216
1392,185.25,216
1416,188,216
1440,190.8125,216
1464,193.5625,216
1128,154.1875,240
1152,156.75,240
1176,159.375,240
1200,161.9375,240
1224,164.5,240
1248,167.1875,240
1272,169.875,240
1296,172.625,240
1320,175.4375,240
1344,178.0625,240
1368,180.875,240
1392,183.6875,240
1416,186.5,240
1440,189.5,240
1464,192.4375,240
1128,151,264
1152,153.6875,264
1176,156.4375,264
1200,159.125,264
1224,161.875,264
1248,164.75,264
1272,167.5,264
1296,170.3125,264
1320,173.25,264
1344,176.125,264
1368,179.125,264
1392,182.0625,264
1416,185.125,264
1440,188.1875,264
1464,191.3125,264
1128,147.6875,288
1152,150.5,288
1176,153.3125,288
1200,156.1875,288
1224,159.125,288
1248,162.0625,288
1272,165.0625,288
1296,168.125,288
1320,171.1875,288
1344,174.25,288
1368,177.3125,288
1392,180.5,288
1416,183.6875,288
1440,186.9375,288
1464,190.25,288
1128,143.625,318
1152,146.6875,318
1176,149.6875,318
1200,152.75,318
1224,155.875,318
1248,159,318
1272,162.25,318
1296,165.625,318
1320,168.875,318
1344,172.125,318
1368,175.375,318
1392,178.75,318
1416,182.125,318
1440,185.6875,318
1464,189.1875,318
1128,139.875,348
1152,143.125,348
1176,146.3125,348
1200,149.5,348
1224,152.9375,348
1248,156.1875,348
1272,159.75,348
1296,163.1875,348
1320,166.625,348
1344,170.125,348
1368,173.75,348
1392,177.125,348
1416,180.75,348
1440,184.5,348
1464,188.25,348
1128,136.25,378
1152,139.6875,378
1176,143.125,378
1200,146.5625,378
1224,150.125,378
1248,153.6875,378
1272,157.375,378
1320,164.6875,378
1344,168.3125,378
1368,172.0625,378
1416,179.625,378
1440,183.5,378
1464,187.4375,378
1128,132.5625,415.25
1152,136.125,415.25
1176,139.8125,415.25
1200,143.4375,415.25
1224,147.1875,415.25
1248,151,415.25
1272,154.875,415.25
1296,158.6875,415.25
1320,162.625,415.25
1344,166.5625,415.25
1368,170.5,415.25
1392,174.375,415.25
1416,178.5625,415.25
1440,182.6875,415.25
1464,186.875,415.25
1128,130.9375,444
1152,134.625,444
1176,138.625,444
1200,142.1875,444
1224,146,444
1248,149.9375,444
1272,153.9375,444
1296,157.9375,444
1320,162,444
1344,166,444
1368,170.125,444
1392,174.25,444
1416,178.375,444
1440,182.625,444
1464,186.875,444
1128,130.8125,474
1152,134.625,474
1176,138.5625,474
1200,142.5,474
1224,146.4375,474
1248,150.5,474
1272,154.5625,474
1296,158.6875,474
1320,162.875,474
1344,166.9375,474
1368,171.25,474
1392,175.5,474
1416,179.75,474
1440,184,474
1464,188.375,474
1128,132.1875,501
1152,136.125,501
1176,140.125,501
1200,144.1875,501
1224,148.25,501
1248,152.375,501
1272,156.5,501
1296,160.75,501
1320,165,501
1344,169.25,501
1368,173.5625,501
1392,177.75,501
1416,182.3125,501
1440,186.75,501
1464,191.125,501
1128,135.25,528
1152,139.375,528
1176,143.375,528
1200,147.5,528
1224,151.625,528
1248,155.8125,528
1272,160,528
1296,164.25,528
1320,168.625,528
1344,172.875,528
1368,177.25,528
1392,181.625,528
1416,186.25,528
1440,190.625,528
1464,195.125,528
1128,142.125,564
1152,146.25,564
1176,150.4375,564
1200,154.5625,564
1224,158.6875,564
1248,162.9375,564
1272,167.1875,564
1296,171.5,564
1320,176.0625,564
1344,180.375,564
1368,184.875,564
1392,189.25,564
1416,193.75,564
1440,198.3125,564
1464,202.8125,564
1128,153.4375,600
1152,157.5,600
1176,161.75,600
1200,165.9375,600
1224,170.125,600
1248,174.25,600
1272,178.625,600
1296,182.9375,600
1320,187.25,600
1344,191.625,600
1368,196,600
1392,200.375,600
1416,204.75,600
1440,209.25,600
1464,213.375,600
1128,169.4375,636
1152,173.4375,636
1176,177.5625,636
1200,181.6875,636
1224,185.875,636
1248,190.0625,636
1272,194.25,636
1296,198.375,636
1320,202.375,636
1344,206.75,636
1368,211,636
1392,215.3125,636
1416,219.5,636
1440,223.8125,636
1464,228.0625,636
1128,190.25,672
1152,194.1875,672
1176,198.25,672
1200,202.125,672
1224,206.1875,672
1248,210.125,672
1272,214.1875,672
1296,218.1875,672
1320,222.1875,672
1344,226.25,672
1368,230.3125,672
1392,234.375,672
1416,238.375,672
1440,242.5,672
1464,246.5625,672
1128,207.0625,696
1152,211,696
1176,214.875,696
1200,218.75,696
1224,222.625,696
1248,226.5625,696
1272,230.4375,696
1296,234.3125,696
1320,238.125,696
1344,242,696
1368,245.75,696
1392,249.75,696
1416,253.5,696
1440,257.375,696
1464,261.125,696

SDO_BUFFER does not work correct with multipolygons

I have a table with two columns (both are SDO_GEOMETRY type): GEOMETRY, GEOMETRY_BUF. DIMs described here.
GEOMETRY has a multipolygon's data, and GEOMETRY_BUF initially is null.
In this case, multipolygon consists of three polygons. Two of them are rather close each other and the third rather far away of them.
If I make a picture of GEOMETRY, I see this multipolygon.
I want to make a buffer (40 Meters) around source GEOMETRY and store it in GEOMETRY_BUF column.
When I do
UPDATE <table_name> o
SET GEOMETRY_buf =
SDO_GEOM.sdo_buffer (o.geometry,
40,
0.005,
'unit=Meter')
I get this result. Two closest polygons are buffered and the third is not. Why? Is it correct work of SDO_BUFFER? How can I get buffer for all polygons in multipolygon?
For example I exported my multipolygon in WKT:
MULTIPOLYGON (((11517.3061 -9316.7092, 11529.4693 -9333.942, 11555.3268 -9327.1603, 11562.6917 -9326.0185, 11566.605 -9324.4166, 11571.5728 -9322.2463, 11586.1288 -9304.1955, 11586.3399 -9301.5948, 11587.3251 -9298.9264, 11592.4594 -9286.2345, 11593.9652 -9284.8561, 11595.4255 -9284.1372, 11596.5791 -9283.6721, 11599.1906 -9272.413, 11598.7147 -9270.787, 11598.6688 -9269.7593, 11598.9953 -9267.4162, 11599.2833 -9260.5784, 11600.4061 -9254.4651, 11600.8117 -9252.2374, 11601.9351 -9246.7015, 11604.1515 -9232.7613, 11607.0962 -9232.6711, 11615.6972 -9170.744, 11616.4172 -9162.8411, 11616.6891 -9158.0432, 11627.6428 -9094.6279, 11629.6001 -9095.5922, 11629.3366 -9092.1316, 11631.5555 -9082.0765, 11632.8241 -9083.1318, 11634.5937 -9075.8674, 11635.0901 -9073.2819, 11635.9144 -9070.4804, 11636.6806 -9067.7817, 11638.1409 -9061.6117, 11633.7683 -9058.316, 11646.0166 -9040.509, 11641.0401 -9037.0454, 11653.3747 -9021.7212, 11650.196 -9018.1182, 11648.4066 -9018.2336, 11644.782 -9015.2088, 11650.852 -9010.3256, 11654.2871 -9009.2253, 11669.9179 -9010.2253, 11720.1392 -9016.1985, 11731.7194 -9017.3642, 11731.5166 -9019.2802, 11736.6782 -9019.9719, 11736.7853 -9018.7664, 11749.4779 -9021.0705, 11765.8132 -9026.2263, 11857.5513 -9037.9299, 11966.7418 -9051.5303, 11972.4873 -9052.451, 11994.0993 -9055.6882, 11996.1523 -9056.1488, 11999.63 -9053.9715, 12003.9456 -9053.3434, 12014.7974 -9053.8877, 12017.661 -9054.3485, 12022.7308 -9054.8928, 12025.161 -9054.8928, 12031.1944 -9055.2278, 12035.5519 -9057.4889, 12038.6524 -9061.0479, 12043.7444 -9060.8216, 12077.8782 -9062.1275, 12084.4548 -9063.3493, 12113.8626 -9063.9861, 12128.2805 -9064.1125, 12130.3243 -9063.9469, 12150.4336 -9063.2307, 12167.0437 -9062.4302, 12176.091 -9062.2625, 12199.5307 -9059.4819, 12202.6969 -9059.2285, 12231.4571 -9055.896, 12243.5404 -9054.5544, 12245.7198 -9053.4103, 12274.8773 -9048.3674, 12290.6727 -9050.8067, 12294.9517 -9050.0068, 12327.292 -9042.063, 12344.4067 -9037.7978, 12346.242 -9037.4565, 12391.9687 -9023.8071, 12398.1063 -9020.9474, 12408.3162 -9018.1104, 12429.1036 -9011.8187, 12430.8981 -9011.0625, 12449.412 -9003.7979, 12452.021 -9002.1045, 12469.1388 -8995.9601, 12477.3695 -8991.5786, 12485.0655 -8987.2142, 12490.8813 -8986.5569, 12496.5895 -8984.2888, 12500.2345 -8981.4022, 12496.6582 -8979.3404, 12503.9482 -8976.8661, 12505.9427 -8974.873, 12508.5561 -8973.5671, 12526.9668 -8964.5841, 12527.7841 -8964.1724, 12527.0391 -8962.6698, 12525.9945 -8959.9635, 12545.0275 -8949.9202, 12537.6746 -8935.4885, 12522.0017 -8943.8274, 12519.5198 -8939.6064, 12516.6895 -8940.6073, 12515.3832 -8940.4332, 12514.0541 -8941.2897, 12508.3293 -8944.0449, 12495.4599 -8950.4538, 12468.1586 -8962.986, 12444.6639 -8972.5394, 12428.2482 -8978.8925, 12400.9305 -8988.7393, 12394.4426 -8991.1326, 12388.8952 -8994.0223, 12383.4503 -8997.1529, 12378.6102 -8999.4454, 12364.5548 -9003.9435, 12352.9546 -9007.5255, 12338.5855 -9011.7029, 12326.9941 -9014.5796, 12316.5813 -9017.4109, 12306.2679 -9019.8897, 12275.8562 -9026.4099, 12245.4496 -9031.7417, 12244.8164 -9031.1515, 12243.7607 -9028.9633, 12243.4366 -9024.2847, 12242.5967 -9013.3541, 12241.7196 -9002.0434, 12240.8619 -8990.8109, 12240.6915 -8987.5548, 12240.2224 -8985.5038, 12239.1962 -8982.6324, 12236.5281 -8979.1164, 12233.2102 -8975.5594, 12224.3816 -8967.0235, 12219.2801 -8962.2476, 12216.6083 -8958.9244, 12215.4355 -8956.4339, 12214.7318 -8952.6542, 12214.3789 -8946.7751, 12213.9674 -8943.4579, 12205.4844 -8943.3108, 12193.6645 -8942.6623, 12187.8324 -8942.4268, 12179.0549 -8941.8675, 12178.5575 -8952.025, 12173.9688 -8951.9348, 12173.2373 -8956.6863, 12137.179 -8956.148, 12096.9046 -8955.5806, 12072.6849 -8955.0751, 12071.8174 -8959.7383, 12071.0884 -8962.767, 12069.4055 -8966.8211, 12066.5207 -8971.7762, 12055.2777 -8987.8869, 12053.1284 -8993.4112, 12047.2713 -9017.5838, 12044.7177 -9027.5265, 12042.7207 -9032.159, 12041.0314 -9034.3577, 12030.2937 -9033.259, 12025.1998 -9032.5631, 12018.5597 -9031.8282, 12008.7749 -9030.5464, 11993.9822 -9028.8158, 11964.1147 -9025.1168, 11931.9949 -9021.2305, 11903.2389 -9017.5607, 11869.9007 -9013.3788, 11854.2524 -9011.4378, 11849.3783 -9010.7419, 11833.972 -9008.9627, 11820.2536 -9007.0812, 11811.0943 -9006.0119, 11806.4564 -9005.5227, 11799.3724 -9004.726, 11788.9519 -9003.4448, 11779.9774 -9002.3294, 11762.6791 -9000.302, 11745.7853 -8998.3151, 11733.713 -8996.7672, 11720.8818 -8995.3079, 11710.4156 -8993.782, 11704.9489 -8993.0308, 11701.0088 -8992.5708, 11695.6894 -8992.0022, 11695.4709 -8993.2528, 11673.4915 -8989.4577, 11658.8434 -8987.8902, 11651.3959 -8987.6881, 11643.9279 -8988.2379, 11638.6407 -8990.2075, 11633.2176 -8995.5848, 11627.7199 -9005.2128, 11630.2139 -9006.0015, 11633.1601 -9005.7462, 11631.4338 -9009.3567, 11629.8444 -9013.3731, 11628.1059 -9022.7272, 11620.7125 -9065.8639, 11612.6646 -9112.3891, 11606.0407 -9149.0436, 11598.7388 -9190.8477, 11593.518 -9190.0813, 11593.4893 -9190.3618, 11591.7738 -9202.1942, 11589.7359 -9216.182, 11592.211 -9216.5848, 11591.4994 -9221.1432, 11590.0714 -9231.6108, 11588.6906 -9239.0181, 11586.804 -9249.3457, 11584.3679 -9262.3566, 11581.9729 -9275.2702, 11580.8806 -9278.5236, 11579.6367 -9283.8945, 11578.7402 -9287.6448, 11576.8692 -9293.0215, 11576.206 -9294.8746, 11577.4629 -9295.5171, 11576.1189 -9297.1819, 11574.2319 -9299.1565, 11570.3322 -9302.0706, 11566.4074 -9303.6443, 11517.3061 -9316.7092)), ((10538.4742 -8841.2167, 10538.6639 -8841.5457, 10544.9465 -8853.5, 10551.3783 -8872.8042, 10554.5243 -8884.1815, 10555.2509 -8885.8567, 10557.827 -8886.6746, 10559.0489 -8888.9592, 10571.6983 -8902.7622, 10574.545 -8905.3676, 10580.8993 -8903.8126, 10597.1667 -8902.4227, 10616.3734 -8901.9774, 10635.512 -8901.6073, 10637.4876 -8901.9308, 10638.6234 -8903.6374, 10639.3915 -8906.6898, 10642.8334 -8906.4259, 10648.2058 -8905.5424, 10665.7825 -8907.31, 10681.0741 -8909.263, 10681.6512 -8909.2836, 10682.1315 -8909.2608, 10693.8507 -8910.3155, 10731.3851 -8914.7496, 10733.0698 -8915.0904, 10735.9988 -8915.7746, 10750.5638 -8917.5374, 10753.8272 -8917.8934, 10757.1473 -8918.3705, 10787.7923 -8922.1505, 10794.3772 -8923.1417, 10815.6217 -8925.8811, 10816.9768 -8926.095, 10818.1847 -8926.3152, 10850.1503 -8930.1685, 10851.2995 -8930.3241, 10852.1192 -8930.4447, 10868.2313 -8932.2611, 10869.3052 -8932.3788, 10870.1776 -8932.4695, 10905.0859 -8936.5665, 10907.4676 -8936.6715, 10910.3953 -8936.6376, 10939.4131 -8939.2791, 10940.8482 -8939.4525, 10950.2279 -8940.0207, 10952.7124 -8940.8332, 10959.8717 -8942.8604, 10975.9668 -8944.922, 10981.9756 -8945.3701, 11000.7514 -8947.7017, 11009.3897 -8948.7799, 11015.5355 -8949.6099, 11043.6417 -8952.9002, 11044.5144 -8952.9856, 11045.2173 -8953.0615, 11067.3801 -8955.8486, 11088.9024 -8958.4083, 11092.6234 -8958.7459, 11095.6822 -8958.9571, 11135.1145 -8963.8183, 11140.6309 -8964.0983, 11145.0648 -8964.3669, 11162.6926 -8966.6076, 11163.3881 -8966.7434, 11164.0096 -8966.8596, 11180.5324 -8969.1097, 11199.5574 -8971.4323, 11221.0843 -8974.2465, 11239.2522 -8976.8548, 11245.1983 -8978.5082, 11251.235 -8980.8821, 11250.3725 -8978.6263, 11246.1124585523 -8971.80830570151, 11242.56 -8969.44, 11231.7364552193 -8948.84886602689, 11217.0541 -8925.6894, 11213.3112 -8917.3115, 11210.1468 -8918.8818, 11205.3016 -8920.782, 11199.9478 -8922.4514, 11191.2742 -8923.3632, 11183.0279 -8922.6215, 11106.6557 -8912.6317, 11082.6826 -8909.0616, 11075.3835 -8908.3282, 11065.6164 -8907.122, 11051.3778 -8905.5613, 11013.6152 -8900.7517, 10936.1757 -8890.3295, 10931.6433 -8889.8599, 10905.6915 -8886.3948, 10903.3464 -8885.8436, 10875.8391 -8882.2496, 10874.6141 -8894.5925, 10864.2529 -8893.1555, 10845.4027 -8891.1401, 10841.7585 -8890.7481, 10828.2582 -8889.1333, 10807.0956 -8886.6983, 10797.1383 -8885.9752, 10793.1993 -8885.8332, 10786.118 -8885.2747, 10773.3137 -8884.339, 10773.5838 -8873.6785, 10774.3714 -8870.8341, 10772.3193 -8870.678, 10736.8864 -8866.4972, 10720.866 -8864.9853, 10699.0454 -8862.6108, 10676.7543 -8860.422, 10635.4306 -8856.0725, 10621.9695 -8853.8424, 10618.4888 -8853.2852, 10606.0549 -8851.5404, 10565.5093 -8843.3367, 10540.9357 -8838.9567, 10538.4742 -8841.2167)), ((10221.8371 -8957.8509, 10217.1186 -8962.6979, 10219.0379729471 -8964.10190901034, 10220.6004 -8961.6653, 10232.954 -8970.56, 10233.8362905777 -8971.28528018161, 10235.2527 -8969.9665, 10240.0855 -8966.6092, 10244.616 -8964.6875, 10255.769 -8961.7291, 10268.9498 -8959.8529, 10290.5463 -8956.7022, 10301.3344 -8955.6404, 10321.9246 -8952.0537, 10331.5377 -8949.8614, 10345.8532 -8947.2152, 10347.3674 -8947.0233, 10349.2175 -8946.8118, 10358.8055 -8945.0906, 10372.8704 -8942.2893, 10374.694 -8941.9433, 10377.1011 -8941.5033, 10380.9646 -8940.7237, 10380.428 -8938.4085, 10380.6233 -8937.3177, 10382.1165 -8935.5334, 10383.1352 -8934.4308, 10386.9636 -8933.4023, 10423.2803 -8926.4318, 10452.4406 -8920.8922, 10481.5725 -8915.3077, 10487.8745 -8914.5586, 10491.0085 -8913.9281, 10505.4779 -8913.9322, 10501.0623 -8883.1909, 10493.401 -8890.3654, 10491.2496 -8892.2846, 10481.7211 -8898.5785, 10476.3494 -8901.8754, 10468.6564 -8903.8349, 10440.8296 -8909.3713, 10425.5145 -8911.9444, 10397.8383 -8917.0854, 10397.5418 -8915.6779, 10391.6426 -8916.0696, 10385.1585 -8917.1572, 10384.9504 -8915.73, 10379.3754 -8916.7551, 10379.7809 -8918.4479, 10373.2752 -8919.8289, 10366.7923 -8921.4868, 10366.8454 -8922.952, 10360.5463 -8924.1291, 10359.3586 -8915.993, 10356.6492 -8916.5285, 10349.5194 -8917.7408, 10350.0602 -8920.6712, 10348.4466 -8920.9851, 10349.0963 -8925.2217, 10348.7279 -8926.2747, 10304.2728 -8934.49, 10302.8419 -8934.7084, 10300.8211 -8934.5268, 10298.7765 -8932.7239, 10296.5626 -8930.0269, 10287.0894 -8932.3249, 10287.0894 -8936.0426, 10286.2385 -8938.1585, 10284.9042 -8939.4247, 10271.4539 -8942.1365, 10270.3542 -8942.3011, 10261.2789 -8944.0258, 10239.8799 -8947.9821, 10237.935 -8948.5705, 10226.9395 -8953.7191, 10221.8371 -8957.8509)))

Smoothing measured data in MATLAB?

I have measured data from MATLAB and I'm wondering how to best smooth the data?
Example data (1st colum=x-data / second-colum=y-data):
33400 209.11
34066 210.07
34732 212.3
35398 214.07
36064 215.61
36730 216.95
37396 218.27
38062 219.52
38728 220.11
39394 221.13
40060 221.4
40726 222.5
41392 222.16
42058 223.29
42724 222.77
43390 223.97
44056 224.42
44722 225.4
45388 225.32
46054 225.98
46720 226.7
47386 226.53
48052 226.61
48718 227.43
49384 227.84
50050 228.41
50716 228.57
51382 228.92
52048 229.67
52714 230.02
53380 229.54
54046 231.19
54712 231.00
55378 231.5
56044 231.5
56710 231.79
57376 232.26
58042 233.12
58708 232.65
59374 233.51
60040 234.16
60706 234.21
The data in the second column should be monoton but it isn't. How to make it smooth?
I could probably invent a short algorithm myself but I think it's a better way to use an established and proven one... do you know a good way to somehow integrate the outliners to make it a monoton curve!?
Thanks in advance
Monotone in your case is always increasing!
See the options below (1. Cobb-Douglas; 2. Quadratic; 3. Cubic)
clear all
close all
load needSmooth.dat % Your data
x=needSmooth(:,1);
y=needSmooth(:,2);
n=length(x);
% Figure 1
logX=log(x);
logY=log(y);
Y=logY;
X=[ones(n,1),logX];
B=regress(Y,X);
a=exp(B(1,1));
b=B(2,1);
figure(1)
plot(x,y,'k*')
hold
for i=1:n-1
plot([x(i,1);x(i+1,1)],[a*x(i,1)^b;a*x(i+1,1)^b],'k-')
end
%Figure 2
X=[ones(n,1),x,x.*x];
Y=y;
B=regress(Y,X);
c=B(1,1);
b=B(2,1);
a=B(3,1);
figure(2)
plot(x,y,'k*')
hold
for i=1:n-1
plot([x(i,1);x(i+1,1)],[c+b*x(i,1)+a*x(i,1)^2; c+b*x(i+1,1)+a*x(i+1,1)^2],'k-')
end
%Figure 3
X=[ones(n,1),x,x.*x,x.*x.*x];
Y=y;
B=regress(Y,X);
d=B(1,1);
c=B(2,1);
b=B(3,1);
a=B(4,1);
figure(3)
plot(x,y,'k*')
hold
for i=1:n-1
plot([x(i,1);x(i+1,1)],[d+c*x(i,1)+b*x(i,1)^2+a*x(i,1)^3; d+c*x(i+1,1)+b*x(i+1,1)^2+a*x(i+1,1)^3],'k-')
end
There are also some cooked functions in Matlab such as "smooth" and "spline" that should also work in your case since your data is almost monotone.

Resources