Addressing a variable in Matlab

WeeG

TS Contributor
#1
Hi Guys,

I have a very simple and silly question....

I have used the import wizard in matlab to open an excel spreadsheet. the wizard has created 3 items: A data matrix, a vector with the headers (names of the variables, X1 X2 Y) and a vector of text data.

Now I want to use some function, let's say to calculate mean or median of the variable X1. How do I do that ? I know I can write data:),1) and get the column I need, but can't I tell matlab which column I need using the variable names themselves, like I do in R, SAS or any other software ? If I can, how ?

ah, and one more thing, after I imported the data from Excel, and I want to save it as a MAT file, will the saving process handle the variables headers too ?

cheers !
 
#2
No, in Matlab you refer to columns and rows when you work with data. When you save a Matlab file everything, including variables you define, will be saved.

It is possible to work with symbolic variables by the 'syms' statement, but thats not what your after i think.