Introduction to Matlab What is Matlab Brief overview
Introduction to Matlab • What is Matlab? – Brief overview, purchasing & installation • Using the Command Window – As a calculator – As a graphing tool – To compute basic statistics • Using the Editor to create scripts and functions • Interactivity: Input/Output • Non-standard statistics and simulation 1
What is Matlab? • Matlab is a statistical analysis, visualization, and scripting language – Used widely in the physical and engineering sciences – Becoming more and more popular in the social sciences 2
3 What is Matlab? • Matlab is a statistical analysis, visualization, and scripting language – Used widely in the physical and engineering sciences – Becoming more and more popular in the social sciences Excel? SPSS? SASS? Python?
Acquiring Matlab • Matlab is available for purchase: – Professional/academic license: $500 basic package (+$200 for statistics toolbox) – Student license: $50 basic package (+$50 for statistics toolbox) – Licenses are tied to the installation computer (Mac or PC) and do not expire. • Visit: – https: //www. mathworks. com/products/matlab. html 4
1. Using the Command Window • As a calculator – Basic operations with scalars, vectors, and matrices • As a graphing tool – Scatter plots, line plots, bar graphs, histograms • To compute standard statistics – Mean, median, mode, quantile, max/min, sorting, and randomization – T-tests, correlation, regression, polynomial fitting, ANOVAs 5
2. Using the Editor Window • To create scripts: – Save a list of commands – Define iterative operations • To create functions: – Defining input and output variables 6
3. Interactivity • Example 1: Survey questions – Ask user a series of questions (of various formats) – Save data in Matlab, and in Excel • Example 2: Interact with an image – Load and display an image of a face – Ask user to click on the eyes and nose – Save x, y positions of the mouse clicks 7
4. Nonparametric statistics • Example: Bootstrap analysis • Load a sample data set (heights from before) • Compute the Bootstrap standard error of the mean – Take an n-sample with replacement – Record the mean of the n-sample – Repeat many times – Display the distribution of means 8
5. Other demos • Face modeling 9
Future workshops Workshop 2: Matlab Research Tools for Social Scientists • Friday, November 2, 3 -5 pm, Social Sciences 2, room 121 • This workshop I will cover a variety of research tools in Matlab, including designing surveys and behavioral studies, randomizing variables and conditions, collecting user responses (button presses, mouse clicks, reaction times), saving and loading data individual and group data. Workshop 3. Data Analysis and Plotting in Matlab • Friday, February 1, 3 -5 pm, Social Sciences 2, room 121 • This workshop will cover more advanced examples of data analysis and plotting using Matlab’s statistics toolbox. Statistical tests included t-tests, ANOVA, correlation, and multiple regression. Plotting functions included scatter, line plots, bar graphs, and histograms. Workshop 4. Visualizing Multivariate Data in Matlab • Friday, February 15, 3 -5 pm, Social Sciences 2, room 121 • In this 2 -hour workshop I presented methods for plotting and visualizing multivariate data involving 3 or more variables. These included 3 D scatter plots, surface plots, and dynamic displays using Matlab video and graphing tools. 10
Future workshops (cont. ) Workshop 5. Introduction to Matlab (refresher) • Friday, April 12, 3 -4 pm, Social Sciences 2, room 121 • This workshop will cover the basics of Matlab; using the Command Window for defining variables, conducting standard statistical analyses, making 2 D plots, and using the Editor to create iterative scripts. Workshop 6. Nonparametric statistics • Friday, April 26, 3 -5 pm, Social Sciences 2, room 121 • This workshop will introduce nonparametric statistics, including rank-order statistics and the Bootstrap Method, that involve minimal assumptions about the underlying data distributions. Workshop 7. Computational simulation • Friday, May 10, 3 -5 pm, Social Sciences 2, room 121 • This workshop will introduce the use computational simulations for modeling irregular or non-parametric data. Examples include leave-one-out analyses, Monte Carlo simulation, and iterative parameter searches. . 11
Questions? • Please visit me during my statistical consultation office hours: – Fall quarter: Tuesdays 2 -4 pm (or by appointment), SS 2 -377 – Winter & Spring: TBA (check https: //csass. ucsc. edu/consulting/consultants. html ) • Email me: – ndaviden@ucsc. edu • All workshop materials will be posted at: – https: //davidenko. sites. ucsc. edu/matlab-workshops/ 12
- Slides: 12