uigetfile only let me choose file from the current folder.how can i choose from anywhere?

these is my code:
% --- Executes on button press in ImSelect.
function ImSelect_Callback(hObject, eventdata, handles)
% hObject handle to ImSelect (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% global pathname;
% global filename;
[filename,pathname] = uigetfile('*.jpg');
f=open(fullfile(pathname,filename) );
selected=sprintf('%s',filename);
i=imread(selected); %reading your .jpg image
axis(handles.axes1); %setting the image in axes1 component -look at thag property of axes which is default axes1
imshow(i)
handles.pathname = pathname;
handles.filename = filename;
guidata( hObject, handles )
when I try to choose a jpg from any other folder than the current one, it makes a mistake sound and nothing opens..how to repait this?

 採用された回答

Iain
Iain 2014 年 9 月 15 日
編集済み: Iain 2014 年 9 月 15 日
selected=sprintf('%s',filename);
should be
selected=sprintf('%s',fullfile(pathname,filename));

3 件のコメント

Sagi
Sagi 2014 年 9 月 15 日
yeah it works, but now each time I choose a file it shows me that window:
how can i cancel it?
Iain
Iain 2014 年 9 月 15 日
I'm pretty certain you don't need "f=open(fullfile(pathname,filename) ); ", which pops that window up.
Sagi
Sagi 2014 年 9 月 15 日
yep,now it works! thanks alot Iain!!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeApp Building についてさらに検索

タグ

質問済み:

2014 年 9 月 15 日

コメント済み:

2014 年 9 月 15 日

Community Treasure Hunt

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

Start Hunting!

Translated by