Conversion to cell from double is not possible. error occurs

3 次查看(过去 30 天)
function varargout = AddRow(varargin)
% ADDROW MATLAB code for AddRow.fig
% ADDROW, by itself, creates a new ADDROW or raises the existing
% singleton*.
%
% H = ADDROW returns the handle to a new ADDROW or the handle to
% the existing singleton*.
%
% ADDROW('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in ADDROW.M with the given input arguments.
%
% ADDROW('Property','Value',...) creates a new ADDROW or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before AddRow_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to AddRow_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 AddRow
% Last Modified by GUIDE v2.5 05-Jan-2019 02:11:54
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @AddRow_OpeningFcn, ...
'gui_OutputFcn', @AddRow_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 AddRow is made visible.
function AddRow_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 AddRow (see VARARGIN)
% Choose default command line output for AddRow
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes AddRow wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = AddRow_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 PB1.
function PB1_Callback(hObject, eventdata, handles)
% hObject handle to PB1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
clc;
data = get(handles.uitable1, 'data');
data(end+1,:) = 0;
set(handles.uitable1, 'data', data)
% --- Executes when entered data in editable cell(s) in uitable1.
function uitable1_CellEditCallback(hObject, eventdata, handles)
% hObject handle to uitable1 (see GCBO)
% eventdata structure with the following fields (see UITABLE)
% Indices: row and column indices of the cell(s) edited
% PreviousData: previous data for the cell(s) edited
% EditData: string(s) entered by the user
% NewData: EditData or its converted form set on the Data property. Empty if Data was not changed
% Error: error string when failed to convert EditData to appropriate value for Data
% handles structure with handles and user data (see GUIDATA)
  2 个评论
dpb
dpb 2019-1-5
data{end+1,:} = 0;
maybe? (I don't do GUIs but I believe from the message and what I know of uitables, data is a cell aray...
It would help if you would have included the actual error message that would tell us which line it was that actually threw the error...
Image Analyst
Image Analyst 2019-1-5
Looks right dpb (so maybe should be down below in the Answers section).
ALI, see the FAQ for an explanation.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Entering Commands 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by