https://github.com/jake-w-liu/meshgrid.jl
MeshGrid.jl is a simple Julia module that provides functionality similar to MATLAB's meshgrid function.
https://github.com/jake-w-liu/meshgrid.jl
julia
Last synced: 5 months ago
JSON representation
MeshGrid.jl is a simple Julia module that provides functionality similar to MATLAB's meshgrid function.
- Host: GitHub
- URL: https://github.com/jake-w-liu/meshgrid.jl
- Owner: jake-w-liu
- License: mit
- Created: 2024-06-07T06:20:17.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-07-09T13:59:32.000Z (almost 2 years ago)
- Last Synced: 2025-04-05T04:27:05.085Z (about 1 year ago)
- Topics: julia
- Language: Julia
- Homepage:
- Size: 19.5 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MeshGrid.jl
[](https://github.com/akjake616/MeshGrid.jl/actions/workflows/CI.yml)
## Overview
`MeshGrid.jl` is a simple Julia module that provides functionality similar to MATLAB's `meshgrid` function. It generates coordinate matrices from vectors or ranges, which are useful for evaluating functions over a grid in two or three dimensions.
## Installation
To install `MeshGrid.jl`, use the following command in the Julia REPL:
```julia
using Pkg
Pkg.add("MeshGrid")
```
## Some Examples
These examples illustrate how `MeshGrid.jl` can handle different data types and mixed types. This flexibility makes it easier to translate MATLAB code into Julia, providing a familiar interface for those transitioning from MATLAB to Julia. Note that the element data type of the output grid will be the promotion of the input element data types.
### Example 1: Creating 2D Grid from Range
```julia
x = -1:1:1
y = -1:0.5:1
X, Y = meshgrid(x, y)
```
### Example 2: Mixing Integers and Floats in 2D Grid
```julia
x = 1:3 # integer range
y = [1.0, 2.5, 4.0] # Float vector
X, Y = meshgrid(x, y) # elements are promoted to Float64
```
### Example 3: Fusing Different Data Types to form 3D Grid
```julia
x = 1:3 # integer range
y = [1.0, 2.5, 4.0] # float vector
z = ["alice", "bob"] # string vector
X, Y, Z = meshgrid(x, y, z) # elements are promoted to Any
```