Hello everyone!
I have two vectors: vect_number_subjects, each position is the number of subjects in a specific folder, and vect_TR, which is the respetive Repetition Time (TR) for those subjects in each folder. The variable number_subjects is the total of subjects present in the folder to be analyzed.
number_subjects = length(dirFicheiroMat);
vect_number_subjects = [15 23 24 33 36 36 37 39 41 44 48 59 61 75 113 169];
vect_TR = [2.2 2.5 1.5 2 1.5 2 2 2.5 3 2 2 1.6 2 3 2 2];
I want to perform a for loop that allows me to calculate the sampling frequency (1/TR) automaticaly, based on the number of subjects present in the folder to be analyzed in that particular moment.
I appreciate any ideas to solve this problem.
Thanks in advance

 채택된 답변

Star Strider
Star Strider 2021년 2월 22일

0 개 추천

It is not obvious to me how the number of subjects and the repitition time interact, however it is unlikely that a loop is necessary in any event.
See if this does what you want:
vect_number_subjects = [15 23 24 33 36 36 37 39 41 44 48 59 61 75 113 169];
vect_TR = [2.2 2.5 1.5 2 1.5 2 2 2.5 3 2 2 1.6 2 3 2 2];
Fs = vect_number_subjects ./ vect_TR;
.

댓글 수: 5

Iugo
Iugo 2021년 2월 22일
편집: Iugo 2021년 2월 22일
So basically I will choose the folder to be analyzed, and I want to create a code that, knowing the number of subjects in that folder, gives me the respective TR of that folder (maybe through indexes), for then use that TR in sampling frequency calculation and other calculations that will arise from that. I wanted this to be generalized to whatever folder was chosen... It's more clear now @Star Strider?
Ok I just got it!
number_subjects = length(dirFicheiroMat);
vect_number_subjects = [15 23 24 33 36 36 37 39 41 44 48 59 61 75 113 169];
vect_TR = [2.2 2.5 1.5 2 1.5 2 2 2.5 3 2 2 1.6 2 3 2 2];
for j=1:length(vect_number_subjects)
if number_subjects == vect_number_subjects(j)
value = vect_number_subjects(j);
idx = find(vect_number_subjects==value);
TR = vect_TR(idx);
fs = 1/TR;
end
end
But now I have another problem... since I have two 36 in vect_number_subjects and their respective value in vect_TR is different, when I run those two folders I get an error... how can I differentiate both?
Star Strider
Star Strider 2021년 2월 22일
I still do not understand what you are doing.
One way could be to decide between the two of them on the basis of ‘vect_TR’, since that appears to be unique with respect to the associated elements of ‘vect_number_subjects’, although you would need to determine that criterion.
Iugo
Iugo 2021년 2월 23일
Star Strider
Star Strider 2021년 2월 23일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

질문:

2021년 2월 22일

댓글:

2021년 2월 23일

Community Treasure Hunt

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

Start Hunting!

Translated by