Index in position 1 exceeds array bounds (must not exceed 1) -- cannot fix behavior script
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
nines
le 27 Nov 2020
Commenté : Walter Roberson
le 27 Nov 2020
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 commentaires
Réponse acceptée
Walter Roberson
le 27 Nov 2020
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 commentaires
Walter Roberson
le 27 Nov 2020
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;
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur MRI dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!