MatLab GUI Load .mat File 导入mat文件
?
在MatLab中,我們用GUI時,有時候需要導(dǎo)入mat格式的圖片,但是在GUI中調(diào)用load和在命令行里調(diào)用load不一樣,在命令行里調(diào)用load('im.mat'),加載進(jìn)去是uint8的矩陣,但是我們在GUI中寫代碼加進(jìn)去,默認(rèn)得到的是一個struct結(jié)構(gòu)體,如果我們此時強(qiáng)行用imshow來顯示導(dǎo)入的數(shù)據(jù),會出現(xiàn)如下錯誤:
??? Error using ==> iptcheckinput
Function 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.
?
為了取出其中的圖片數(shù)據(jù),可浪費(fèi)了我好幾個小時候,終于找到了方法,這樣我們就可以在GUI中的axes中顯示出圖片了,參見如下:
?
% Load im.mat filename = uigetfile('*.mat'); img = cell2mat(struct2cell(load(filename)));axes(handles.axes_1);
imshow(img);
?
轉(zhuǎn)載于:https://www.cnblogs.com/grandyang/p/5150922.html
總結(jié)
以上是生活随笔為你收集整理的MatLab GUI Load .mat File 导入mat文件的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 通过电机编码器AB相输出确定电机转向
- 下一篇: [leetcode] Bulb Swit