What does this for-loop do?

for i=1:numSubj(group)
subj=cell2mat(subjIDs{group}{1}(i, :))
subjDir=[/somewhere/somewhere];
v=dlmread(subjDir);
FCall=(i, :, :)=v;
end

8 comentarios

Adam Danz
Adam Danz el 13 de Jul. de 2018
It doesn't do anything because there are multiple errors that will cause a break. Please format your code using the {} button and include line breaks where needed. If you have more specific questions, follow-up.
Golnar
Golnar el 13 de Jul. de 2018
Editada: Geoff Hayes el 13 de Jul. de 2018
for i=1:numSubj(group)
subj=cell2mat(subjIDs{group}{1}(i, :))
subjDir=[/somewhere/somewhere/];
v=dlmread(subjDir);
FCall=(i, :, :)=v;
end
Geoff Hayes
Geoff Hayes el 13 de Jul. de 2018
Golnar - where did you get this code? Please provide a link or some context so we can get an idea of what group, numSubj, etc. are.
Adam Danz
Adam Danz el 13 de Jul. de 2018
Here are at least 2 lines that will break
  • [/somewhere/somewhere/]
  • FCall=(i, :, :)=v
The only way to reverse engineer this code is if it works in the first place. I'd like to help more but the code doesn't do anything as long as it's breaking. I agree with Geoff's comment - knowing the source of the code and what the variables mean would be another good starting point.
Golnar
Golnar el 13 de Jul. de 2018
I was looking for an answer like, "when the iteration is at 1, for the group defined numSubj, the code is going to convert the group into..." and so on.
Geoff Hayes
Geoff Hayes el 13 de Jul. de 2018
But what is group? A number or a string or something else? numSubj is probably an array but is it a numeric, character or cell array? Again, where did you get this code from?
Adam Danz
Adam Danz el 13 de Jul. de 2018
Here's a brief look at what's going on and it's very vague because the code is vague.
for i=1:numSubj(group) %Loop through 1 to some other number defined by numSubj(group)
subj=cell2mat(subjIDs{group}{1}(i, :)) %subj should be a matrix if the code works. subjIDs is a cell array of cell arrays.
subjDir=[/somewhere/somewhere]; % ??? (will break)
v=dlmread(subjDir); % see 'help dlmread'
FCall=(i, :, :)=v; % ?? This will break
end
Golnar
Golnar el 13 de Jul. de 2018
Thank you. I'm a Research Assistant adapting a script to fit our current set up.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 13 de Jul. de 2018

Comentada:

el 13 de Jul. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by