matlab2016agui出错,关于 gui运行出错的问题

MATLAB R2016B win64。。我做了一个简单的gui,功能是实现选择一个图像并打开它。在guide编辑器中运行它是没问题的。但是将其保存成fig文件之后运行就会报错。

报错内容为

“结构体内容引用自非结构体数组对象。

出错 xvanzetuxiang>pushbutton1_Callback (line 84)

axes(handles.axes1);

出错 gui_mainfcn (line 95)

feval(varargin{:});

出错 xvanzetuxiang (line 42)

gui_mainfcn(gui_State, varargin{:});

出错

matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)xvanzetuxiang('pushbutton1_Callback',hObject,eventdata,guidata(hObject))

计算 UIControl Callback 时出错 "

具体代码为  “function varargout = xvanzetuxiang(varargin)

% XVANZETUXIANG MATLAB code for xvanzetuxiang.fig

%      XVANZETUXIANG, by itself, creates a new XVANZETUXIANG or raises the existing

%      singleton*.

%

%      H = XVANZETUXIANG returns the handle to a new XVANZETUXIANG or the handle to

%      the existing singleton*.

%

%      XVANZETUXIANG('CALLBACK',hObject,eventData,handles,...) calls the local

%      function named CALLBACK in XVANZETUXIANG.M with the given input arguments.

%

%      XVANZETUXIANG('Property','Value',...) creates a new XVANZETUXIANG or raises the

%      existing singleton*.  Starting from the left, property value pairs are

%      applied to the GUI before xvanzetuxiang_OpeningFcn gets called.  An

%      unrecognized property name or invalid value makes property application

%      stop.  All inputs are passed to xvanzetuxiang_OpeningFcn via varargin.

%

%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one

%      instance to run (singleton)".

%

% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help xvanzetuxiang

% Last Modified by GUIDE v2.5 27-Nov-2017 22:12:11

% Begin initialization code - DO NOT EDIT

gui_Singleton = 1;

gui_State = struct('gui_Name',       mfilename, ...

'gui_Singleton',  gui_Singleton, ...

'gui_OpeningFcn', @xvanzetuxiang_OpeningFcn, ...

'gui_OutputFcn',  @xvanzetuxiang_OutputFcn, ...

'gui_LayoutFcn',  [] , ...

'gui_Callback',   []);

if nargin && ischar(varargin{1})

gui_State.gui_Callback = str2func(varargin{1});

end

if nargout

[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});

else

gui_mainfcn(gui_State, varargin{:});

end

% End initialization code - DO NOT EDIT

% --- Executes just before xvanzetuxiang is made visible.

function xvanzetuxiang_OpeningFcn(hObject, eventdata, handles, varargin)

% This function has no output args, see OutputFcn.

% hObject    handle to figure

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

% varargin   command line arguments to xvanzetuxiang (see VARARGIN)

% Choose default command line output for xvanzetuxiang

handles.output = hObject;

% Update handles structure

guidata(hObject, handles);

% UIWAIT makes xvanzetuxiang wait for user response (see UIRESUME)

% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.

function varargout = xvanzetuxiang_OutputFcn(hObject, eventdata, handles)

% varargout  cell array for returning output args (see VARARGOUT);

% hObject    handle to figure

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure

varargout{1} = handles.output;

% --- Executes on button press in pushbutton1.

function pushbutton1_Callback(hObject, eventdata, handles)

% hObject    handle to pushbutton1 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

[filemane,pathname]=uigetfile({'*.jpg';'*.bap';'*.tif'},'选择图片');

str=[pathname filemane];

im = imread(str);

axes(handles.axes1);

imshow(im);

% --- Executes on button press in pushbutton2.

function pushbutton2_Callback(hObject, eventdata, handles)

% hObject    handle to pushbutton2 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

close(gcf)

2017-11-29 15:14 上传

442a53943febe9465fc072b4fbe10813.gif

b2a5a3e0dcc7d508e00275fe42fce1b5.gif

在编辑器中运行正常

9e48288f4ed8c95052a66736b318254d.png

  • 2
    点赞
  • 0
    收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
©️2022 CSDN 皮肤主题:游动-白 设计师:我叫白小胖 返回首页
评论
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值