Old value of an updated variable still has an effect on the output (in this particular case). Why?
1 view (last 30 days)
Show older comments
%%First question; please pardon if I didn't provide sufficient/relevant info.
Problem: the value assigned to "that_particular_figure" before the loop messes-up the output.
If you want a bit of context/background: Some images were read (imread), their corresponding textures made (MakeTexture), drawn later (DrawTexture) in this program. The textures are stored in "stimulus_tex". "tex" takes the value of one texture at a time (as per the trial) and it is then, later, drawn. The sequence of the stimuli is of utmost importance here. The "set_of_images" contains all the images whose textures are to be drawn (there are those that are not to be drawn; counterbalanced for each participant) and was used to make the array "stimulus_tex". That is why their index is same, even though the name of the shape (the corresponding number out of 1:24) varies. This loop ensures that the correct texture is put into "tex" for each of the trials. If I use "that_particular_figure" before and then also in the loop, the image sequence goes haywire. ( My guess: the texture is getting assigned both values somehow).
%%This is the code that kind-of does the job. I have just recently started out ...so... still a victim of several malpractices. Suggestions welcomed!
%%running the test
while(1)
for trial = 1:number_of_trials
% set the texture and its position to correspond the current trial
% we have to find out which index of "set_of_images" does "that_particular_figure" correspond to!!!!
% that_particular_figure = stimulus_showing_order(trial);
% this line above ^ is the code that I used when it didn't work properly
assigning_a_different_variable_works = stimulus_showing_order(trial);
for index_in_set_of_images = 1:12 % and whichever "set_of_images" 's index it is, it
% will be at the same index in stimulus_textures
if assigning_a_different_variable_works == set_of_images(index_in_set_of_images)
that_particular_figure = index_in_set_of_images;
else
continue
end
end
% "stimulus_tex" has only 12 cells (textures). The 'number' of our image ranges from 1:24. To find a link between
% this number and it's texture that was made earlier, we use the following logic :-
tex = stimulus_tex{that_particular_figure};
% The textures in "stimulus_tex" and "set_of_images" have the same index. Therefore, by getting the index (from set_of_images)
% of our image number (out of 24), we draw that precise texture.
end
3 Comments
Answers (0)
See Also
Categories
Find more on Image display and manipulation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!