Okay, I am going to start this section with a few disclaimers. This is not a statistics course, therefore, I am not going to teach any statistics. With that said, I will be assuming you do know the basics of statistics here at an introductory graduate level. However, if you do not have this knowledge you can still do these tutorials - you just might not understand some of the concepts but you can still learn the code.
To start with, we are going to load the text file HERE into MATLAB. Download this file now and make sure it is in your tutorial directory.
Loading the file is easy. Use the following commands first so we start from scratch:
clc;
clear all;
close all;
To load the file, simply use:
my_data = readtable('my_data.txt');
This tells MATLAB to load the file my_data.txt into a variable called my_data. Further, we are going to use a new variable type - a table - for all statistical work as it allows us to use logical indexing which is very powerful.
A few things to note.
One, the default assumption here is that the data in my_data.txt is tab delimited text. If you data is not in that format you will have to "tweak" readtable. You can try help readtable to see your options. Second, loading data is one million times easier if it is all numeric. If some of it is text, this gets challenging very, very quickly. However, IF you save your data in a .mat format and are smart with variables then this is trivial. So, if you program your experiments in MATLAB you can make this a non-issue, if you use third party software loading data can get quite difficult quite quickly. Just a warning. Indeed, in future work we will specify the table at the outset and save it as a table with column names already in place.
Go ahead and look at the new variable my_data. You will note it was 100 rows and three columns. This is simulated data from a Stroop task. Column One is the participant number from 1 to 50 and you will note that it repeats indicating that this is a dependent or within design (everyone does both Stroop conditions). Column Two reflects the condition code, 1 or 2 for congruent or incongruent. Column Three reflects the mean reaction time for each participant for each condition. Double click on the variable name in the workspace so you can see what is in the variable.
We can easily change the names of the table columns using:
my_data.Properties.VariableNames = {'Subject' 'Condition' 'RT'};
That is it for this tutorial. We will build on this first step in the next tutorial.
To start with, we are going to load the text file HERE into MATLAB. Download this file now and make sure it is in your tutorial directory.
Loading the file is easy. Use the following commands first so we start from scratch:
clc;
clear all;
close all;
To load the file, simply use:
my_data = readtable('my_data.txt');
This tells MATLAB to load the file my_data.txt into a variable called my_data. Further, we are going to use a new variable type - a table - for all statistical work as it allows us to use logical indexing which is very powerful.
A few things to note.
One, the default assumption here is that the data in my_data.txt is tab delimited text. If you data is not in that format you will have to "tweak" readtable. You can try help readtable to see your options. Second, loading data is one million times easier if it is all numeric. If some of it is text, this gets challenging very, very quickly. However, IF you save your data in a .mat format and are smart with variables then this is trivial. So, if you program your experiments in MATLAB you can make this a non-issue, if you use third party software loading data can get quite difficult quite quickly. Just a warning. Indeed, in future work we will specify the table at the outset and save it as a table with column names already in place.
Go ahead and look at the new variable my_data. You will note it was 100 rows and three columns. This is simulated data from a Stroop task. Column One is the participant number from 1 to 50 and you will note that it repeats indicating that this is a dependent or within design (everyone does both Stroop conditions). Column Two reflects the condition code, 1 or 2 for congruent or incongruent. Column Three reflects the mean reaction time for each participant for each condition. Double click on the variable name in the workspace so you can see what is in the variable.
We can easily change the names of the table columns using:
my_data.Properties.VariableNames = {'Subject' 'Condition' 'RT'};
That is it for this tutorial. We will build on this first step in the next tutorial.