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.

Load values from a file into a script

Load values from a file into a script - MATLAB Tutorial

From the course: MATLAB 2018 Essential Training

Start my 1-month free trial

Load values from a file into a script

- [Instructor] In the previous movie, I showed you how to write data to an external file. In this movie, I will show you how to read values from an external file into a MATLAB variable. I have just started MATLAB and I have a clean command window ready to go. So the first thing I need to do is create a file with some values. I'll start by defining a variable called mat1, and then an equal sign for the assignment, and I will create the first row with the values four through 16 going up in increments of four. So I'll type four then a colon, my step value is four colon, and the top value is 16. Then a semicolon to indicate I have a new row, and then we'll do five through 20 going up by five for the second row. So five colon five colon 20. Right square bracket and Enter, and there I get my two by four matrix. If I want to save these values in a file, then I'd need to use the save function. A space, then I will call the file matrixdata.dat. I don't need to add the extension. It can just be…

Contents