I want to create the surface plot by surface command for my sets of data.
2 views (last 30 days)
Show older comments
Prateek Srivastava
on 21 Apr 2018
Commented: Walter Roberson
on 25 Apr 2018
In my data there is temperature in one column,speed in one column and modulus of elasticity in one column.I would like to take temperature as X and Speed as Y and Modulus of elasticity as Z.I am trying to use the surface command but it is showing error such as 'Data dimension must agree',I am attaching the script please find the attachment.
3 Comments
Accepted Answer
Walter Roberson
on 21 Apr 2018
You have scattered data; it is not possible to surface() it.
N = 20; mins = min(A); maxs = max(A); [Temperature, Speed] = ndgrid(linspace(mins(1),maxs(1),N), linspace(mins(2),maxs(2),N)); F = scatteredInterpolant(A(:,1),A(:,2),A(:,3)); vq = F(Temperature,Speed); surf(Temperature, Speed, vq);
9 Comments
Walter Roberson
on 25 Apr 2018
No, scatteredInterpolant cannot return equations.
You could in theory replicate the functionality by using a Delaunay triangulation to divide the surface up into triangles according to which points are closest. That done, you could go through and construct a table of linear constraints that define the boundaries of each of the triangles, along with the triangular interpolation coefficients that are relevant to the interior of that triangle. That done, if you have the Symbolic Toolbox, you could construct a big piecewise() -- if the x, y have this relationship then this calculation, if the x, y have this other relationship then this other calculation, and so on.
You will likely find that in practice, optimization over such a piecewise equation does not work very well.
But I suspect that what you are really looking for is a single non-piecewise surface equation generated out of the known points. If so, then the answer is that given any finite number of points specified to finite precision, and corresponding result values, that there are an infinite number of surface equations that fit the points exactly (to within round-off).
This is the infinity of continuous numbers, the uncountable infinity, not the mere countable infinity, so it turns out that allowing for the possibility that the measurements might not be exact (noise in the system or imprecision in the readings) does not increase the number of potential solutions, since as far as we can tell there is no "larger" infinity except as pure abstractions.
When there are an infinite number of possible functions that all fit the known data exactly (to round-off) then the probability that any given function is the "real" function for the system is precisely zero.
The situation is extremely different if you know the form of the function and are just missing the values of the coefficients. You do not have enough data to fit anything more complicated than a cubic in one of your variables with a quadratic in the other (total power 6), and it should be obvious from the surface plot that a surface that simple is not an adequate explanation for the surface you are getting. But it is possible, you can fit up to 6 degrees of freedom with 7 data points, if you know the form of the equation.
More Answers (0)
See Also
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!