matrixinputjuliafile-read# Reading data matrix from text file in Julia

I have text file which includes a matrix. I want to read it in julia as a matrix.

The text file is like:

```
0 0 0 0 0 0 0
1 0 0 0 0 0 0
1 0 0 0 0 0 1
1 0 0 0 1 1 0
```

In matlab you can do the following to create matrix `M`

:

```
file='name.txt';
[M] = load(file);
```

How to do same thing in Julia?

Solution

```
shell> cat /tmp/m.txt
0 0 0 0 0 0 0
1 0 0 0 0 0 0
1 0 0 0 0 0 1
1 0 0 0 1 1 0
using DelimitedFiles
julia> m = readdlm("/tmp/m.txt")
4x7 Array{Float64,2}:
0.0 0.0 0.0 0.0 0.0 0.0 0.0
1.0 0.0 0.0 0.0 0.0 0.0 0.0
1.0 0.0 0.0 0.0 0.0 0.0 1.0
1.0 0.0 0.0 0.0 1.0 1.0 0.0
```

- Print 2-D Array in clockwise expanding spiral from center
- Assign values based on reverse combination of two columns
- R - Reshape list with matrices
- How to split a square matrix into cubes without loops
- is it possible to evaluate a function of matrix variables in mathematica?
- Pretty print 2D list?
- Why are quaternions used for rotations?
- Multiple values in one tile with geom_tile
- How to put number of a particular element in a particular row and column constraints in a matrix?
- How to calculate a Kernel/Matrix efficiently
- What's the best way to create a "3D identity matrix" in Numpy?
- How to compute exponential of a matrix inside CUDA thread?
- How to get element-wise matrix multiplication (Hadamard product) in numpy?
- Why does dim=1 return row indices in torch.argmax?
- How to unnest a "list" in a martix?
- Can not update matrix entries for large matrices
- How do I make a matrix from a list of vectors in R?
- Sum two array rows in PHP on a single line
- Get indices of matrix from upper triangle without numpy
- How to read scalar, vector and matrix information in string format resembling Python syntax in R?
- Cache-friendly sqare matrix transposition logic issue
- How to select winner of condorcet election via matrix?
- solve rectangular matrix in python to get solution with arbitrary parameters
- Sum of a list of matrices in R
- Submatrix Ocaml
- Parameterizing type definition at compile time
- How to make a symmetric matrix where the sum of each row and column is k when the diagonal elements are certain (not zero) in excel?
- MPI4PY: Scatter a matrix
- Fill the Diagonal of Each Matrix in a 3D numpy Array with a Vector
- Rotate UVs in Vertex Shader without distorting texture