I have a text file in the same folder as my matlab code called matlab.in, its contents are
training_set = [1 2 3; 4 5 6]
How do I read this matrix into a variable called training_set?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Your text file contains an executable Matlab statement. You could, probably even should, rename it to something like
training_set.m(the.msuffix is important) and simply ‘read’ it from the command line by executing it. On my machine the ‘command’generates the response
and, hey presto, the variable
training_setis now safely ensconced in your workspace.Now congratulate yourself for having written your first (?) Matlab script, reward yourself with a visit to the documentation to review this important topic.