ghazal
ghazal

Reputation: 13

how to present .mat data in matlab

I imported my data from excel to matlab and saved it as 't.mat'.I used function:

load('t.mat')
open('t.mat') 
ans =
ndata: [62x8 double]
text: {63x9 cell}
alldata: {63x9 cell}

but it did not show the data.I want to see the column 5 of the data an plot it,so i wrote :

x=t.mat(:,5) 
plot(x)

the error was : ??? Attempt to reference field of non-structure array.

please help me to present the data and plot it. thanks

Upvotes: 0

Views: 132

Answers (3)

Anael
Anael

Reputation: 414

't.mat' is just the name of the file where your data is stored. When you load a file, it loads the content into your workspace with the saved variable names, here ndata, text and alldata.

You then need to call the variables themselves to access the data:

load('t.mat')
x = ndata(:,5);
plot(x)

Upvotes: 0

Benoit_11
Benoit_11

Reputation: 13945

You can load your data into a structure and easily access them:

DataStruct = load('t.mat');

A = DataStruct.alldata; % Assign a variable to alldata. 

plot(A{:,5});

Following on @Darthbit's comment, once you load the .mat file ,variables are available in the workspace, so you could use something like this:

load('t.mat');
plot(alldata{:,5})

Upvotes: 1

Bryan Linton
Bryan Linton

Reputation: 456

I haven't used Matlab in a while but I'm pretty sure you can't just say:

x=t.mat(:,5)

I think you have to store the t.mat into something. Here's a page that might be helpful: http://www.mathworks.com/help/matlab/ref/load.html#btm3ohm-1

Upvotes: 0

Related Questions