- 积分
- 46
- 注册时间
- 2007-4-28
- 仿真币
-
- 最后登录
- 1970-1-1
|
发表于 2010-9-25 14:00:42
|
显示全部楼层
来自 河北廊坊
关于数据传递的方式比较多
1.使用全局变量(global)
2.GUI数据(handles),guidata
3.Application数据
4.UserData属性
下面是我根据你的代码修改后的代码
-
- function my_pushb_2_Callback(hObject, eventdata, handles)
- % hObject handle to my_pushb_2 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- pic_dir=uigetdir('start_path','请选择图片所在的目录');
- handles.pic_dir=pic_dir;
- if pic_dir
- str_all=dir([pic_dir '\*.jpg']);
- str_all=[str_all dir([pic_dir '\*.bmp'])];
- % {str_all.name}=[]
- set(handles.my_list_1,'string',{str_all.name});
- else
- warndlg('打开的目录不能为空','敬告!');
- end
- guidata(hObject,handles);
复制代码-
- function my_list_1_Callback(hObject, eventdata, handles)
- % hObject handle to my_list_1 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- % Hints: contents = get(hObject,'String') returns my_list_1 contents as cell array
- % contents{get(hObject,'Value')} returns selected item from my_list_1
- if isequal(get(gcf,'SelectionType'),'open')
- str=get(hObject,'string');
- n=get(hObject,'value');
- current_pic=imread(fullfile(handles.pic_dir,str{n}));
- imshow(current_pic);
- end
- guidata(hObject,handles);
复制代码 |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?注册
×
评分
-
1
查看全部评分
-
|