Subscript indices must either be real positive integers or logicals

조회 수: 1 (최근 30일)
hello recently I'm learning matlab. i have this problem:
j = read(img);
u=im2bw(img);
imshow(u);
and main:
if[imgName,path] = uigetfile('*.jpg','Select the MATLAB code file');
img=imread([path imgName]);
j =read(img );
matlab error:Subscript indices must either be real positive integers or logicals. how can I read an image by main function that using other read function?
  댓글 수: 4
elena rondina
elena rondina 2016년 1월 26일
편집: elena rondina 2016년 1월 26일
ok error message is:
if Subscript indices must either be real positive integers or logicals.
Error in re (line 4)
j =main(k );
read is A function that you've written.what is this error?what's the solution?
Star Strider
Star Strider 2016년 1월 26일
What is ‘main’?
What is the value of ‘k’?

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

채택된 답변

Image Analyst
Image Analyst 2016년 1월 26일
편집: Image Analyst 2016년 1월 26일
Why do you have "if" in this line:
if[imgName,path] = uigetfile('*.jpg','Select the MATLAB code file');
Try getting rid of that if, and just start with the brackets. Or better yet, try more robust code like this:
% Have user browse for a file, from a specified "starting folder."
% For convenience in browsing, set a starting folder from which to browse.
startingFolder = 'C:\Program Files\MATLAB'; % Wherever you want....
if ~exist(startingFolder, 'dir')
% If that folder doesn't exist, just start in the current folder.
startingFolder = pwd;
end
% Get the name of the file that the user wants to use.
defaultFileName = fullfile(startingFolder, '*.jpg');
[baseFileName, folder] = uigetfile(defaultFileName, 'Select a file');
if baseFileName == 0
% User clicked the Cancel button.
return;
end
fullFileName = fullfile(folder, baseFileName)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Dialog Boxes에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by