Index in position 1 exceeds array bounds (must not exceed 1) -- cannot fix behavior script
1 回表示 (過去 30 日間)
古いコメントを表示
Hello!
I need help with my behavior script -- I am trying to plot a .mat file that has the dimensions of ans: [2×8297 double]. When I run it through a behavior script I am getting the error Index in position 1 exceeds array bounds (must not exceed 1).
I understand that the .mat file and its dimensions are the problem -- but how do I fix it?
Any help would be much appreciated, I have tried converting it to a txt file but haven't had any luck!
subject='racsleep04'
run='run01'
clicks=load(['racsleep04_a_run01_clicks.mat'])
%%
starttime = clicks(2,1); %HAVING ERROR ON THIS LINE
bp = clicks(2, find((clicks(1,:)~=22)&(clicks(1,:)~=0)))- starttime;
%% figure
figure(); subplot(2,1,1); plot(bp, ones(length(bp),1), '*'); title(['Button Press Times ', subject, ' ', run])
xlabel('Time');
subplot(2,1,2); plot(bp(2:end), diff(bp), '*'); title(['Button Press Intervals ', subject,' ', run]); xlabel('Time'); ylabel('Time since last click')
0 件のコメント
採用された回答
Walter Roberson
2020 年 11 月 27 日
When you load() and assign the output to a variable, the result is a struct with one field for each variable loaded.
clickstr = load(['racsleep04_a_run01_clicks.mat']);
clicks = clickstr.clicks;
2 件のコメント
Walter Roberson
2020 年 11 月 27 日
In the above code, clickstr would be a struct with a field named for each variable stored in the file. Based on context it looks like you were expecting the file to have a variable named clicks, but if the variable name in the file is something else, then you need to use that on the line
clicks = clickstr.FileVariableNameGoesHere;
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!