Unable to display a selected image despite finding no errors while running the code
Afficher commentaires plus anciens
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);
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Image display and manipulation dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!