Generates a 2-D mesh grid from two vectors a and b, generating two matrices len(a) x len(b) with all all possible combinations of values between the two vectors. This method is analogous to MATLAB/Octave's meshgrid function.
Namespace: Accord.MathAccord.Math (in Accord.Math.dll) Version: 3.8.0
Syntaxpublic static Tuple<T[,], T[,]> MeshGrid<T>( this T[] x, T[] y )
<ExtensionAttribute> Public Shared Function MeshGrid(Of T) ( x As T(), y As T() ) As Tuple(Of T(,), T(,))Request Example View Source Parameters
Type:
TupleT,
TA tuple containing two matrices: the first containing values for the x-coordinates and the second for the y-coordinates.
Usage NoteIn Visual Basic and C#, you can call this method as an instance method on any object of type . When you use instance method syntax to call this method, omit the first parameter. For more information, see
Extension Methods (Visual Basic)or
Extension Methods (C# Programming Guide).
Examples// The MeshGrid method generates two matrices that can be // used to generate all possible (x,y) pairs between two // vector of points. For example, let's suppose we have // the values: // double[] a = { 1, 2, 3 }; double[] b = { 4, 5, 6 }; // We can create a grid var grid = a.MeshGrid(b); // get the x-axis values // | 1 1 1 | double[,] x = grid.Item1; // x = | 2 2 2 | // | 3 3 3 | // get the y-axis values // | 4 5 6 | double[,] y = grid.Item2; // y = | 4 5 6 | // | 4 5 6 | // we can either use those matrices separately (such as for plotting // purposes) or we can also generate a grid of all the (x,y) pairs as // double[,][] xy = x.ApplyWithIndex((v, i, j) => new[] { x[i, j], y[i, j] }); // The result will be // // | (1, 4) (1, 5) (1, 6) | // xy = | (2, 4) (2, 5) (2, 6) | // | (3, 4) (3, 5) (3, 6) |
See AlsoRetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4