Yingqiang Gao
Yingqiang Gao

Reputation: 999

python import .mat file: how to just import one wanted column from a matrix

I have this .mat file D887_ALL.mat and there are several matrices in it, one is called trigger_events and is a 671×2 matrix. I will only use the first column. Can I just import the first column in Python?

This is what I can do now, just import the whole matrix events:

dataFile='/Users/gaoyingqiang/Desktop/Python/D887_All.mat'
data=scio.loadmat(dataFile)
trigger_events=['trigger_events']

How can I do this?

Upvotes: 0

Views: 278

Answers (1)

kmario23
kmario23

Reputation: 61475

How about this if you want just the first column?

trigger_events_col1 = data['trigger_events'][:, 1]

Upvotes: 1

Related Questions