From the course: MATLAB 2018 Essential Training
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Write values to an external file - MATLAB Tutorial
From the course: MATLAB 2018 Essential Training
Write values to an external file
- [Instructor] When you perform calculations in MATLAB, you will usually write the results to a variable. In this movie, I will show you how to write the contents of a variable to a file, append new values to an existing file, and display the contents of those files. I have just run MATLAB and I have a blank command window. That means I need to define the variable. So I'll start by defining a matrix. I'll call it m-a-t-1, an equal sign for assignment, followed by a left square bracket, and I want the numbers one, three, five, and seven. So I'll type a one, a colon, a two, which is my step value, and my end value of seven. Follow that with a semicolon indicating a new row and now I will start with two and go up by two all the way to eight. So 2:2:8. Then a right square bracket, make sure everything looks good. I think it is, Enter, and there I have my matrix. If I want to save this file to a file called Matrix Data, then I use exactly that key word, save. So I'll type save and then the…