playground_05_IO - VMinhoto/workshop-matlab GitHub Wiki
IO
- Console Input
- File Input
- Excel Input
Console Input
It's important to give the user a choice to import some info from the workspace. In order to do this you have the command a=input('Some text \n');
. With this Matlab displays the 'Some text
to the user and stores the inserted value in the variable a
.
age=input('Insert your Age \n');
fprintf('Your age is %d \n',age);
File Input
For simple .txt files, for example just put it in your workspace and execute the command A=importdata(filename)
Some examples and more details can be found in this page
Excel Input
Perhaps the most import file type to import data from in an Engineering course! For a list of commands on how to do this you can consult the documentation. The excel columns will be imported as column vectors.
%Basic excel import
num = xlsread('data.xls');
The previous example will create a matrix num with all non null columns of the file 'data.xls' as column vectors!