How to create a column vector corresponding to number of rows of matrices using for loop?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi everyone,
I am trying to analyze data corresponding to animal behavioral trials. I have a bunch of x by 15 matrices (each represents 1 trial's data; x represents video frames and ranges from 1200 to 3000, but always 15 columns).
I am trying to use a for loop to create a column vector for each of the trials that contains the number of rows for that trial's data. Let's call it nframes. So for example if the trial has 1500 frames, the nframes value for that trial would show up as a column vector with 1500 rows numbered 1 through 1500.
Code thus far (removing unnecessary parts):
for i_trial = i_probe_trials' % for all trials of interest
load(video_trial{i_video_trial}(1:end-2)); % load video data
nframes = ???
traj_y = dlcmat(:,(marker_num_plot-1)*3+2); % get trace from trial
end
What is the easiest way to do this? I've tried a number of things and I'm stuck.
Thank you!
0 commentaires
Réponse acceptée
Rik
le 26 Avr 2023
You should always load to a variable. Then it is a lot easier to see where your variables come from. For this case I expect you need to use the size function. (I had to guess the variable name and this loop is overwriting the results)
for i_trial = i_probe_trials' % for all trials of interest
S=load(video_trial{i_video_trial}(1:end-2)); % load video data
dlcmat=S.dlcmat;
nframes = size(dlcmat,1);
traj_y = dlcmat(:,(marker_num_plot-1)*3+2); % get trace from trial
end
3 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Whos 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!