How can I retrieve a .mat file content (e.g. arrays or matrix)?

Hi, I have a mat file with 10 (columns) x 3 (rows) of data and I would like to retrieve these data to produce some readable output. For example, the first column of data is 1 0 0 and the output will be Yes.
May I know how can I perform the first step, which is how to get/read the data from the mat file? Thank you and your help is greatly appreciated.

Answers (1)

In Matlab comman type
data=load('yourfilename')
What did you get?

11 Comments

-data = load('a12345')
-In the workspace, a variable "data" is created with the value of 1x1 struct
-I double clicked the "data" and saw a field named "a12345" with the value of 1x1 cell.
-Double clicked "a12345" and saw a cell with values. Then double clicked the cell and the values I want to retrieve are shown. How can I get these values?
type data with all fieldnames
data.a12345.values
>> data.a12345.values;
??? Attempt to reference field of non-structure array.
When I tried with data.a12345, an variable named "ans" is created in the workspace with 1 x 1 cell. And the values needed are stored inside that cell.
data.a12345{1,1} will create an variable named "ans" that listed all the values the spreadsheet. For example, row 1 col 1 = 1, row 2 col 1 = 0 and row 2 col 1 = 0. I think this will solve the way to access the variable with the values. So how can I get this value from "ans" in array form?
Now y contains all the values and my last question is how to get the value out from y? For example y contains 0 (col 1 row 1) 0 (col 1 row 2) 1 (col 1 row 3). In my coding, I would like to evaluate these 3 values via if else function. The concept is
if a = 0
if b = 0
if c = 1
......
else
else
else
my concern is how to assign the values in y to a b and c?
size(y)
value [3,1] min 1 max 3
If
y=[1 1 0 1 1;0 0 1 0 1;0 0 0 1 1];
test=all(y(:,1)==[1;0;0]) % if test=1 means yes, 0 means no
@Vivian: You are asking very basic questions. I strongly recommend to read the Getting Started chapters of the documentation, which would explain all fundamental Matlab commands. It is not possible to handle such a powerful tool as Matlab without reading the instructions.

Sign in to comment.

Asked:

on 4 Nov 2012

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!