如何仅显示MATLAB中的文件名和文件大小
-
21-12-2019 - |
题
当我尝试使用轴作为按钮打开图像时,它的显示文件名与源路径。
- 文件名:c:\ users \ win8 \ documents \ matlab \ test \ lena.png
- 文件大小:606.09
我只想在没有十进制的情况下只显示文件名(红色边框),并在kB(蓝色边框)中的文件化。
- 文件名:lena.png
- 文件大小:606
轴1回调码:
function axes1_ButtonDownFcn(hObject, eventdata, handles)
% hObject handle to axes1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
project = guidata(gcbo);
[imgname, imgpath] = uigetfile({'*.png';}, 'Open an Image')
if imgname==0 % if it is canceled
imgname=''; % create an empty name
imgpath=''; % create an empty path
end
if isequal(imgname, 0)
return;
end
eval(['cd ''' imgpath ''';']);
I=imread(fullfile(imgpath, imgname));
set(project.figure1, 'CurrentAxes', project.axes1);
set(imshow(I));
imshow(I);
set(project.figure1, 'Userdata', I);
set(project.axes1, 'Userdata', I);
info = imfinfo(fullfile(imgpath, imgname));
set(project.edit1, 'String', info.Filename);
set(project.edit2, 'String', info.FileSize/1024);
.
如何做到这一点?
我正在使用matlab r2012a。
解决方案
不隶属于 StackOverflow