This question already has an answer here:
- Matlab read in txt file into array 2 answers
I have a text file called coordinates.txt as following format:
0 0 0
-0.95 0.32 -0.02
-1.02 0.26 -0.96
-0.73 0.6 -0.52
-0.77 0.6 -0.71
-0.28 0 -0.95
-0.14 -0.16 0.13
-0.46 -1 -0.29
-1.14 -0.6 0.16
How could I load it in matlab with commands and save it in a matrix called X as following:
X=[0 0 0;
-0.95 0.32 -0.02;
-1.02 0.26 -0.96;
-0.73 0.6 -0.52;
-0.77 0.6 -0.71;
-0.28 0 -0.95;
-0.14 -0.16 0.13;
-0.46 -1 -0.29;
-1.14 -0.6 0.16;]
so each line in the text file will be saved as a row in matrix X.
Type 'help load' for more information.