Unable to display a selected image despite finding no errors while running the code
显示 更早的评论
I am writing the code for the part of my experiment where I am randomly displaying one of the already displayed image, along with a randomly assigned text (again, from a previous display), using PSYCHTOOLBOX on MATLAB. Though I am not getting any errors while I am running the code, only the text is getting displayed. I am unable to understand the error and would be extremely grateful if someone could help me regarding this. I have used two variations of the code, both of which faced the same issue, and I am posting both here for suggestions. Thanks in advance.
Code 1:
% Randomly select one of the stored image-text combinations
randomIndex = randi(numLocations);
% Display the randomly selected image and text
selectedImage = displayedImages{randomIndex};
selectedText = displayedTexts{randomIndex};
% Display the selected image
imageRect = CenterRectOnPointd([0 0 size(selectedImage, 2) size(selectedImage, 1)], xCenter, yCenter-(yCenter/3));
Screen('PutImage', window, selectedImage, imageRect);
% Display the selected text
DrawFormattedText(window, selectedText, 'center', yCenter+(yCenter/3), white);
% Flip the screen to display the image and text
Screen('Flip', window);
Code 2:
% Randomly select one of the stored image-text combinations
randomIndex = randi(numLocations);
% Display the randomly selected image and text
selectedImage = displayedImages{randomIndex};
selectedText = displayedTexts{randomIndex};
% Display the selected image and text
Screen('PutImage', window, selectedImage, CenterRectOnPointd([0 0 size(selectedImage, 2) size(selectedImage, 1)], xCenter, yCenter-(yCenter/3)));
DrawFormattedText(window, selectedText, 'center', yCenter+(yCenter/3), white);
% Flip the screen to display the image and text
Screen('Flip', window);
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Image display and manipulation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!