How can you load a matrix from a file in an octave?

I uploaded an 8-bit grayscale image into an octave with imread, then I saved it in ascii format and got a giant list of all its values. Then I separated it with a 2x2 matrix in Java and printed out a list of each mashed matrix on one line.

If the matrix for a pixel in my program turns out to be like this:

0 2 3 1 

Then the output that my program generates looks like this:

 0 2 3 1 

Then I have all the matrices for each pixel in this format on one row. How can I load this into an octave to see the final image with fade?

I fiddled with the octave and created a simple matrix, such as the first one that I showed, and saved it in a file, then I could put it all on one line and load it again just fine. I then tried to replace the matrix in this file with the matrix created by my program, but the octave does not seem to load it. The matrix she tried to load did not change at all.

+8
matrix octave dithering
source share
1 answer

I do not think that I fully understood your question, but if you have problems interacting with the file system, I suggest using the dlmread and dlmwrite functions.

The following code should serve as an example to run:

 %Random 4 by 4 matrix M = rand(4,4) %Write matrix to file system dlmwrite("filename.txt",M); %Read it back and store in an other variable M2 = dlmread("filename.txt") 
+8
source share

All Articles