Psychtoolbox-3: Error using Screen

조회 수: 2 (최근 30일)
Jade T
Jade T 2022년 12월 30일
댓글: Jade T 2022년 12월 31일
Hi all, this bit of code is from an entire script keeps closing out w/ error and I am not sure why.The error message reads the following:
"Usage:
textureIndex=Screen('MakeTexture', WindowIndex, imageMatrix [, optimizeForDrawAngle=0] [, specialFlags=0] [, floatprecision] [, textureOrientation=0] [,
textureShader=0]);
Error in punishment_ar_att_v3 (line 285)
image = Screen('MakeTexture', onScreen, item);
%%%%%%%%%%%%%%%%%%%
Screen('Preference', 'SkipSyncTests', 1);
%%% Screen Dimensions %%%
screens = Screen('Screens'); %count the screen
minScreens = min(screens);
[onScreen, screenRect] = Screen('OpenWindow', minScreens); % Open the second window
%[ScreenX, ScreenY] = WindowSize(onScreen);
ScreenX = screenRect(3);
ScreenY = screenRect(4);
cx=(ScreenX/2); %Middle of screen on X-axis
cy=(ScreenY/2); %Middle of screen on Y-axis
ScreenRect = [0 0 ScreenX ScreenY]; %Rectangle = size of whole display
cd charities;
charList = dir('*.jpg'); % Get pics
nChar = find([charList.bytes]>1000);
charList = charList(nChar);
nChars = length(charList); % How many?
cd ..;
charTex = zeros(1,length(charList)); % create an empty cell array to store each new texture
for i = 1:length(charList)
cd charities;
item = (charList(i).name);
cd ..;
image = Screen('MakeTexture', onScreen, item);
charTex(i) = image;
end

채택된 답변

Walter Roberson
Walter Roberson 2022년 12월 30일
You are passing a name in, but you need to pass the image content instead. So you need to imread()
  댓글 수: 1
Jade T
Jade T 2022년 12월 31일
Thanks much! This definitely works!

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

추가 답변 (1개)

VBBV
VBBV 2022년 12월 30일
charTex = cell(1,length(charList)); % create an empty cell array to store each new texture
for i = 1:length(charList)
cd charities;
item = (charList(i).name);
%cd ..;
image = Screen('MakeTexture', onScreen, item);
charTex{i} = image;
end
  댓글 수: 1
Jade T
Jade T 2022년 12월 31일
The curly brackets! Thanks much, i knew something was off with the indexing but for some reason I though that the parentheses worked despite it being a cell array

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

카테고리

Help CenterFile Exchange에서 Image display and manipulation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by