extract same row from multiple matrices

2 views (last 30 days)
Sabine
Sabine on 26 Nov 2012
Hi, I have collected data from approx. 100 participants in my study where each row corresponds to (x-axis coordinates only) mouse movements of a particular stimulus. I would like to automate the extraction of the data from all matrices for each row into a new matrix, i.e. all row1s of the 100 matrices end up in Matrix1, all row2s end up in Matrix2 etc.
1. all files are labeled path_person_[# of participant].mat, e.g. path_person_3.mat for participant 3.
2. only extract data from every 100th column (there are 30,000 columns)
3. all files are in the same folder.
How can I achieve that? Thank you!
  4 Comments
Sabine
Sabine on 29 Nov 2012
sorry for the late reply, I was waiting for an email... so when I enter whos x in the command window, it comes back empty (I am using the student version)even though I opened my data file in the variable editor. My matrix is a 196 x 30,000 double matrix and the data in each cell is the coordinate of the mouse movement on the x-axis (y-axis coordinates were fixed), i.e. integers such as "640" "642" etc. all the way to the edge of the screen, depending on the movement. 196 = the number of my stimuli, 30,000 the sampling during the mouse movement in the course of 3 sec. Finally, I currently have data from 80+ participants. Thanks for your help and sorry for my rudimentary understanding of programming!
Sabine
Sabine on 29 Nov 2012
Oh, and my request to extract only part of the data is because I don't think I need that many data points to analyze the hand movement of my participants, i.e. ultimately I want to analyze the start time/reaction time of the mouse movement, direction (i.e. to the left or right of the midpoint of "640") and average and peak velocity of the movement, and finally time of end of movement.

Sign in to comment.

Answers (2)

per isakson
per isakson on 29 Nov 2012
Your matrix, M, is 50MB. Try
M1 = M( :, [ 1 : 100 : 30000 ] );
  4 Comments
Jan
Jan on 7 Jan 2013
I do not have the impression that the email notifications are reliably. Sometimes I get 8 notifications in some minutes from the FileExchange, then no further messages for the next year. Comments to the question do not trigger a notification (or at least did not), although this is important.
Sabine
Sabine on 11 Jan 2013
Thanks for answering my "complaint" about not getting emails. I will check every few days now.
However, the more pressing questions I had were these: so I activated th file with my participant data and entered the above code into the command window and nothing happened. How do I tell matlab that I want it to access all path_person_[# of participant].mat files and extract a particular row. The above code comes back with "??? undefined variable M."
Also, where does the above line put the data? What will be the name of the file? Will it be saved in the file where I have the original data? Will I have to go through the program 196 times to extract the data for all my stimuli one by one, changing the row #? Thanks!

Sign in to comment.


Sabine
Sabine on 11 Jan 2013
Ok, I think I've been using the system incorrectly - I kept commenting on answers rather than posting my questions under "answers".
First, thanks for answering my "complaint" about not getting emails. I will check every few days now.
However, the more pressing questions I had were these:
I activated the file with my participant data and entered the above code into the command window and nothing happened. How do I tell matlab that I want it to access all path_person_[# of participant].mat files and extract a particular row. The above code comes back with "??? undefined variable M."
Also, where does the above line put the data? What will be the name of the file? Will it be saved in the file where I have the original data? Will I have to go through the program 196 times (once for every stimulus) x 80 times (number of participants) to extract the data for all my stimuli one by one, changing the row #? Thanks!
  1 Comment
Image Analyst
Image Analyst on 11 Jan 2013
You were using it correctly (until now). What you posted here is not an answer to your original question, is it? No, so it should either be a comment to someone who answered your question, or an edit of your original question to clarify it. If you don't get emails when comments are added, then that is a deficiency of the forum. Regardless, questions are often answered quickly here - in minutes or hours - so you should check back frequently for updates.

Sign in to comment.

Categories

Find more on Introduction to Installation and Licensing in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!