Write a script that will load data from a file into a matrix. I am confused on how to load data files and call functions in matlab.
1
Expert's answer
2012-02-10T08:01:48-0500
Suppose you have a file "mydata.txt" with the following contents
1 2 3 4 5 6 7 8 9 10 11 12
So here are numbers separeted by spaces ' ' Then the command
M = dlmread('mydata.txt',' ')
will read all the file into the matrix M and print
M =
1 2 3 4 5 6 7 8 9 10 11 12
The first argument of the command 'dlmread' is the file name, and the second one is the separator of numbers. If you numbers are separeted by tabsm, or commas use the commands
Comments
Leave a comment