MatLab GUI Load .mat File 导入mat文件 |
您所在的位置:网站首页 › matlab导入mat文件的命令在哪儿 › MatLab GUI Load .mat File 导入mat文件 |
在MatLab中,我们用GUI时,有时候需要导入mat格式的图片,但是在GUI中调用load和在命令行里调用load不一样,在命令行里调用load('im.mat'),加载进去是uint8的矩阵,但是我们在GUI中写代码加进去,默认得到的是一个struct结构体,如果我们此时强行用imshow来显示导入的数据,会出现如下错误: ??? Error using ==> iptcheckinputFunction IMAGEDISPLAYVALIDATEPARAMS expected its first input, I,to be one of these types: double, single, uint8, uint16, uint32, int8, int16, int32, logical Instead its type was struct.
为了取出其中的图片数据,可浪费了我好几个小时候,终于找到了方法,这样我们就可以在GUI中的axes中显示出图片了,参见如下: % Load im.mat filename = uigetfile('*.mat'); img = cell2mat(struct2cell(load(filename)));axes(handles.axes_1);imshow(img);
|
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |