Getting the piecewise polynomial function of a 3D plot

Is there a method to get the piecewise function of the 3D plot below? My requirement is to get a value for X as the output when Y and Z are given as inputs. The plot is created using the curve fitting tool (linear interpolation)
Inputs should be - z , y
Output should be - x

3 Kommentare

Senal Perera
Senal Perera am 16 Mär. 2021
Bearbeitet: Senal Perera am 16 Mär. 2021
Note that the curve fitting tool does not show the equation. It only says ' Piecewise polynomial'. The data cursor shows the coordinates upon clicking on the plot. But that is not what I want. I want to save the output in to the workspace which i have to feed it into a servo motor.
Why are you using fitting tool GUI? You can do the same using interpolation code in a script.
DGM
DGM am 16 Mär. 2021
Unless I'm missing something, this is a more fundamental problem. If your goal is to get x from y and z, you need to note that your function is overdefined. In other words, there are multiple x values that may satisfy a given y,z pair. The conceptual consequences of that fact may vary depending on your usage.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

ANKUR KUMAR
ANKUR KUMAR am 16 Mär. 2021
Bearbeitet: ANKUR KUMAR am 16 Mär. 2021
You can use interp2 to calculate values programmatically.
clc
clear
[X,Y] = meshgrid(-5:1:5);
Z = Y.*sin(X) - 5*X.*cos(2*Y);
s = surf(X,Y,Z,'FaceAlpha',0.5);
[XX,YY] = meshgrid(-5:0.05:5);
ZZ=interp2(X,Y,Z,XX,YY);
figure
s = surf(XX,YY,ZZ,'FaceAlpha',0.5);
s.EdgeColor = 'none';
x_reqired=randi(50,1,10)/10;
y_reqired=randi(50,1,10)/10;
z_reqired=interp2(X,Y,Z,x_reqired,y_reqired)

1 Kommentar

I appreciate your effort Ankur. I guess interp2 is okay if z is needed as the output. But i need x as the output where z and y are inputs.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Get Started with Curve Fitting Toolbox finden Sie in Hilfe-Center und File Exchange

Produkte

Version

R2019b

Gefragt:

am 16 Mär. 2021

Kommentiert:

am 16 Mär. 2021

Community Treasure Hunt

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

Start Hunting!

Translated by