how to make 2d lookup table when having 3 vectors
9 views (last 30 days)
Show older comments
Hi,
I have 3 vectors each of order 1xn.
namely torque, flux and current. So, depending on the torque and the flux value I need the current as output. I want to use 2d Lookup table for this, but the table data should be nxn. That means my current matrix should be nxn, but my current matrix is actually 1xn. So, is there any way to convert this current vector into matrix, is it possible?
Regards,
Manoj.
0 Comments
Accepted Answer
More Answers (1)
John D'Errico
on 9 Apr 2019
The problem is, your data is insufficient to create a 2-d surface from only that data. (Yes, you CAN use a scatteredInterpolant, but the reult will be very poor.) This is also why I told you in your last question that gridfit is not a good tool to solve the problem.
So why can you not use data like that to form a complete surface, a 2-d lookup table? It lives in only a very small region of the space, almost entirely along one curve, much of that being virtually a straight line. And replicating the data, as you seem to have wanted to do in your last question does not give you more useful information.
You talk about the relationship between torque and flux not being linear. But if they are to be used to populate a 2-d lookup table, you don't want any relationship at all to exist between the DEPENDENT variables of your table. So, why is that type of data not good to populate a 2-d table?
You have never been willing to show me your data, even though I have asked. But here is an example of a similar case, where a similar amount of information exists.
x = linspace(0,1,10);
y = sin(1.5*x);
plot(x,y,'o')
grid on
So, we have some highly dependent variables, x and y. Now suppose we want to create a 2-d lookup table, where some other variable z happens to be a function of x and y. So imagine that you have measured z at each of those points, This is the case you have described. where you have current as a function of flux and torque.
But your data lies only along that narrow band in the (x,y) plane. At any point away from that narrow band, you have no information at what the shape of that surface might be. This will cause gridfit to perform miserably. It will cause a scattered interpolant to fail in flames.
What happens with a scattered interpolant?
tri = delaunay(x,y)
hold on
trimesh(tri,x,y)
The dots wer your data. The triangular mesh is what a scattered interpolant will use to interpolant. At any point, it determines which of those triangles the point lies inside, then uses the z values at the 3 corner vertices of the corresponding triangle to do interpolation. See that EVERY triangle here connects a line segment to the point at the very end.
The goal of a scattered interpolant is to use data that is NEAR a point in question to interpolate. But in a problem like this, that fails miserably. Where are scattered interpolants good? Or, for that matter, where are tools like gridfit good?
A classical problem where scatteredInterpolant is a good tool might be:
x = rand(100,1);
y = rand(100,1);
tri = delaunay(x,y);
plot(x,y,'ro')
hold on
trimesh(tri,x,y)
grid on
Here, at any point in the (x,y) plane, the tool uses those data points that surround any point in question to interpolate the value of z. Even there, extrapolating into the curners becomes a problem (a case where gridfit is designed to operate a little more robustly than a scattered interpolant.) But we don't have a very narrow band of data, so at least within the domain that contains our data, any tool will do reasonably well.
The issue is, you don't seem to have that kind of data. And again, replicating your data does not give you more data. It can just give you more bad data.
See Also
Categories
Find more on Matrix Indexing 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!