Moving vector values into a table using accumarray

1 回表示 (過去 30 日間)
Mary
Mary 2014 年 3 月 18 日
コメント済み: Mary 2014 年 3 月 18 日
Hello I have data from an experiment where each participant has one folder containing three files (baseline, trial 1, trial 2). Each file contains two vectors time and amplitude, (time is not linear)
I'm working on figuring out how to manipulate my data - but I keep getting stuck. (the lengths of the vectors are not consistent)
I need to figure out a way to get this information into a table like what is shown below:
PV Trial Type Time Amp
01 Baseline .015 .23
01 Baseline .201 .30
01 Baseline .450 5.67
01 Trial 1 .012 .34
02 Trial 2 .13 .45
Right now I have it parsing through each file, and using accumarray to place the information into vectors
PV(1).trial(0) = [.23,.3,...]
Below is a chunk of the code I have written (just the for loop for each file)
for f = 1: numberOfFiles
resFileName = fullfile(res_files,baseFileNames(f).name);
rawData = importdata(resFileName,' ');
timeData = rawData.data(:,1);
ampData = rawData.data(:,2);
PID = resFileName(3:5);
binnum = 1 + floor(timeData(:) / 42);
PV(k).trial = accumarray( binnum, ampData(:), [], @(V) {V});
binnum = 1 + floor( (timeData(:)-1) / 42);
end
any feedback would be greatly appreciated! Thank you!!!
  2 件のコメント
Walter Roberson
Walter Roberson 2014 年 3 月 18 日
Heh. You've been getting code from my postings, I see ;-)
Mary
Mary 2014 年 3 月 18 日
Yes I have! I dont really have much of a background with coding - so much of what I work on is figuring out what I want to do in english, and then googling how I accomplish it in code
Thank you for having so many answers online!

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by