Statistics extrapolation on the data

4 次查看(过去 30 天)
I have data in the below format and am not sure what is the best way to extrapolate the data i need with relative good accuracy.
x = [10, 30, 40, 50, 60]..... This is various temperature.
y = [10, 10, 10, 10, 5]........This is the voltage.
z = [1:100,1:100,1:100,1:100,1:100]....The values of the sensor from time 1 to 100 seconds, for x(i) and y(i).
I don't have the data for x = 60 and y = 5. I would like to exterpolate this to remove the dependency on the y value and later will use x, z in combination with other parameters as a gridedinterpolant.
I can just neglect the 60 temp and 5 voltage data i have and completely extrapolate with interp2 and spline method, but somehow it is not giving proper output.
What are the ways i can have the existing data of 60 temp and 5, some effect on the extrapolated data.
I am also open to use the existing data and directly find value for the x, y....But i think interp3 will require meshgrid and values known for each brakepoint.

回答(1 个)

Karan Singh
Karan Singh 2025-2-18
Just a suggstion how about using "scatteredInterpolant". You can read more about it here https://in.mathworks.com/help/matlab/ref/scatteredinterpolant.html
You can first, “vectorize” your data. For example, if for each temperature (x) and corresponding voltage (y) you have 100 time points (z), you can reshape your data into a list of points. Then, build a scattered interpolant using the available (x,y,z) points.
When you query at a new (x,y) (for example, x = 60 and y = 5) the interpolant will perform an interpolation (or even extrapolation if needed) based on your chosen method (like ‘linear’). This way the (x = 60, y = 5) point although “missing” in your original grid is indirectly accounted for by how it relates to its neighbors.
% Example data
x = [10, 30, 40, 50, 60];
y = [10, 10, 10, 10, 5];
z = [linspace(1,100,100);
linspace(1,100,100);
linspace(1,100,100);
linspace(1,100,100);
linspace(1,100,100)];
% Suppose you wish to build an interpolant for a particular time index, say t = 50.
% Alternatively, if you have many time points, you might want to process each time step.
% Here, we choose one value from each row (e.g., column 50).
zVal = z(:,50); % sensor reading at time 50 for each (x,y)
% Now, create a scattered interpolant using the available (x,y) points.
F = scatteredInterpolant(x(:), y(:), zVal(:), 'linear');
% 'linear' extrapolation are chosen here (you can change these options)
% Query the interpolant at the desired point (e.g., x=60, y=5)
query_x = 60;
query_y = 5;
z_query = F(query_x, query_y)
z_query = 50
% z_query will be an extrapolated estimate at (60,5)
disp(z_query);
50
Karan

类别

Help CenterFile Exchange 中查找有关 Sources 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by