I need help in understanding how to use this octave script
http://www.gnuplotting.org/code/save_binary_matrix.m
to generate a binary matrix that I want to plot with gnuplot. Any suggestion will be appreciated even just a web link that would help me to understand octave syntax
thanks
Mariano
Octave syntax
The octave syntax is not that hard to understand. The documentation of the interpreter can be found here.
The main part of the script
can be explained like this:
Line 1 initializes a matrix
MS
of dimensionslength(x) + 1
andlength(y) + 1
wherelength
determines the largest dimension of the argument. Sincex
andy
are in your case vectors,length
returns the dimension of the vector.After in Line 1 the matrix
MS
is created, the length of vectorx
is stored inMS(1,1)
. This is the first row element of the first column ofMS
.Line 3 assigns the rest of the first row (everything from the 2nd element to the end: hence
2:end
the values ofy
.The rest of the first column gets all the values of
x
assigned to.The remaining matrix
MS
now gets all values of the transpose ofM
assigned.You basically end up with a matrix that has the y-axis stored in the first row and the x-axis stored in the first column. The remaining matrix
MS
holds the transpose of matrixM
.Plotting a binary matrix with gnuplot
As described here the format specified above is of the exact format as needed by gnuplot. You now have multiple ways of plotting matrix information. One simple way of testing your binary file is
where
"Data.bin"
has to be substituted for your binary file.A general introduction into plotting 3D information can be found here and there.