필터 지우기
필터 지우기

how to load a file from different folder than our m. file?

조회 수: 1 (최근 30일)
Varian Adisuryo
Varian Adisuryo 2016년 7월 26일
댓글: Varian Adisuryo 2016년 7월 26일
Hi guys, so I want to load image from another file from my m. file using uigetfile. but when I run it, it says "file doesn't exist". please help, tell me the correct code. this is my script on m. file:
a=uigetfile()
filename=a;
setappdata(0,'filename',filename);
a=imread(a);
axes(handles.axes1);
imshow(a);
setappdata(0,'a',a)
setappdata(0,'filename',a);
plot(handles.axes1,'a')

채택된 답변

Adam
Adam 2016년 7월 26일
편집: Adam 2016년 7월 26일
Use the following syntax
[FileName,PathName,~] = uigetfile(FilterSpec)
then
filename = fullfile( PathName, FileName )
to get the full path of the file name.
As an aside your script is extremely confusing. Why are you reusing the variable a to be both a filename initially then the image you read in and then you are setting it on appdata later on under the title of 'filename' again when it is no longer a filename. Giving your variables sensible names is vital for good programming and understandability.
  댓글 수: 1
Varian Adisuryo
Varian Adisuryo 2016년 7월 26일
Thank you so much for your help Mr. Adam. I'm very sorry if my script very confusing, I'm a beginner at this. I will try to correct it. Thank you so much

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Convert Image Type에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by