Queries on [x,y] in the fit function

2 vues (au cours des 30 derniers jours)
Akaash Dragon
Akaash Dragon le 25 Nov 2019
I have a matix where the rows are the x values, columns are the y values and the matrix elements are the z values. I want to try to use the "fit" function in matlab to plot them. (My matrix has 3500 rows and 250 columns)
fitobject = fit([x,y],z,fitType) creates a surface fit to the data in vectors x, y, and z.
I have tried reading the documentation of this function. However, I still don't understand the input parameters [x,y],z should look like.
For example: For x it says "Data to fit, specified as a matrix with either one (curve fitting) or two (surface fitting) columns. You can specify variables in a MATLAB table using tablename.varname. Cannot contain Inf or NaN. Only the real parts of complex data are used in the fit." Why should my x have 2 colums? And what should I put for y inin such a case.
If someone could elaborate on how my the input parameters in more detail, I would be really grateful.

Réponses (1)

Vinay Konanki
Vinay Konanki le 22 Jan 2020
Hii Akaash,
Consider the statement below,
fitobject = fit(X,Z,fitType);
You can consider X (or x mentioned in the documentation) as the first argument to the fit function.
There are two acceptable cases.
  1. The first one being X = x where x is a vector (matrix with a single column).
  2. The second one is X = [x,y] where x and y are vectors which makes X (the first argument to the fit function), a matrix with two columns.
The first case leads to a curve fit where as the later case leads to a surface fit.

Catégories

En savoir plus sur Get Started with Curve Fitting Toolbox dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by