Error while evaluating UIControl Callback
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Dear
I received the following error messages:
"Conversion to cell from double is not possible.
Error in DWRDataProcessing>pushbutton1_Callback (line 280)
d((k+d_begin),1)=visc(k);
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in DWRDataProcessing (line 44)
gui_mainfcn(gui_State, varargin{:});
Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)DWRDataProcessing('pushbutton1_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback."
Hope someone can help out! Below I included a copy of the code.
function varargout = DWRDataProcessing(varargin)
% DWRDATAPROCESSING M-file for DWRDataProcessing.fig
% DWRDATAPROCESSING, by itself, creates a new DWRDATAPROCESSING or raises the existing
% singleton*.
%
% H = DWRDATAPROCESSING returns the handle to a new DWRDATAPROCESSING or the handle to
% the existing singleton*.
%
% DWRDATAPROCESSING('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in DWRDATAPROCESSING.M with the given input arguments.
%
% DWRDATAPROCESSING('Property','Value',...) creates a new DWRDATAPROCESSING or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before DWRDataProcessing_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to DWRDataProcessing_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
% Copyright 2002-2003 The MathWorks, Inc.
% Edit the above text to modify the response to help DWRDataProcessing
% Last Modified by GUIDE v2.5 27-Nov-2012 11:16:44
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @DWRDataProcessing_OpeningFcn, ...
'gui_OutputFcn', @DWRDataProcessing_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 DWRDataProcessing is made visible.
function DWRDataProcessing_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 DWRDataProcessing (see VARARGIN)
% Choose default command line output for DWRDataProcessing
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes DWRDataProcessing wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = DWRDataProcessing_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 selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = get(hObject,'String') returns popupmenu1 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu1
%gets the selected option
global modeselectie
switch get(handles.popupmenu1,'Value')
%1. Oscillatory mode with only lower phase
%2. Oscillatory mode with lower and upper phase
%3. Shear mode with only lower phase
%4. Shear mode with lower and upper phase
case 1
case 2
modeselectie=1;
case 3
modeselectie=2;
case 4
modeselectie=3;
case 5
modeselectie=4;
otherwise
end
% --- Executes during object creation, after setting all properties.
function popupmenu1_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on selection change in popupmenu2.
function popupmenu2_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = get(hObject,'String') returns popupmenu2 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu2
%gets the selected option
global geometrieselectie
switch get(handles.popupmenu2,'Value')
case 1
case 2
geometrieselectie=1;
%disp('Big regular or TA ring')
case 3
geometrieselectie=2;
%disp('Midsize ring')
case 4
geometrieselectie=3;
%disp('Baby ring')
otherwise
end
% --- Executes during object creation, after setting all properties.
function popupmenu2_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% function edit1_Callback(hObject, eventdata, handles)
% % hObject handle to edit1 (see GCBO)
% % eventdata reserved - to be defined in a future version of MATLAB
% % handles structure with handles and user data (see GUIDATA)
%
% % Hints: get(hObject,'String') returns contents of edit1 as text
% % str2double(get(hObject,'String')) returns contents of edit1 as a double
% global pathexcelfile
% pathexcelfile=get(hObject,'String');
% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- 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)
global modeselectie pathexcelfile datapoint geometrieselectie
set(handles.simulationstatus,'String','Running...');
set(handles.convergentietext,'String','No');
set(handles.datapoint,'String','1');
if ispc || ismac
A = xlsread(char(pathexcelfile), 1, 'A2:K1600');
else
A_read = xlsread(char(pathexcelfile), 1);
if isnan(A_read(1,1))
A=A_read(2:end,:);
else
A=A_read(1:end,:);
end
end
% Filling in of all the parameters
if geometrieselectie==1
StressConstant=64.85; % Big Regular and TA ring
elseif geometrieselectie==2
StressConstant=138.44; % Midsize Ring
elseif geometrieselectie==3
StressConstant=259.633; % Baby Ring
end
densitylower=A(:,1);
densityupper=A(:,2);
density=densitylower;
viscositylower=A(:,3);
viscosityupper=A(:,4);
viscosity=viscositylower;
frequency=A(:,5);
angularamplitude=A(:,6);
angularvelocity=A(:,7);
Beginelasticiteit=A(:,8);
Beginviscositeit=A(:,9);
SoftwaretorqueReeel=(A(:,10).*cos(A(:,11)*pi/180))*10^(-6);%./StressConstant;
SoftwaretorqueImaginair=(A(:,10).*sin(A(:,11)*pi/180))*10^(-6);%./StressConstant;
[x,y]=size(A);
for k=1:x
Softwaretorque(k)=SoftwaretorqueReeel(k)+SoftwaretorqueImaginair(k)*i;
end
visc=0;
elast=0;
status=0;
%1. Oscillatory mode with only lower phase
%2. Oscillatory mode with lower and upper phase
%3. Shear mode with only lower phase
%4. Shear mode with lower and upper phase
if modeselectie==1
[visc,elast,status] = DWRLowerPhase_Osc_BG(Beginviscositeit,Beginelasticiteit,Softwaretorque,frequency,density,viscosity,angularamplitude,handles,geometrieselectie);
elseif modeselectie==2
[visc,elast,status] = DWRLowerAndUpperPhase_Osc(Beginviscositeit,Beginelasticiteit,Softwaretorque,frequency,densitylower,densityupper,viscositylower,viscosityupper,angularamplitude,handles);
elseif modeselectie==3
[visc,status] = DWRLowerPhase_Shear_BG(Beginviscositeit,Softwaretorque,density,viscosity,angularvelocity,handles,geometrieselectie);
elast=zeros(size(visc));
elseif modeselectie==4
[visc,status] = DWRLowerAndUpperPhase_Shear(Beginviscositeit,Softwaretorque,viscositylower,viscosityupper,angularvelocity,handles);
elast=zeros(size(visc));
end
if ispc || ismac
d = {'Corrected viscosity', 'Corrected elasticity','Status:1=converged,0=diverged'};
d_begin=1;
else
disp(('Corrected viscosity, Corrected elasticity, Status:1=converged,0=diverged'));
d_begin=0;
end
for k=1:length(visc)
d((k+d_begin),1)=visc(k);
d((k+d_begin),2)=elast(k);
d((k+d_begin),3)=status(k);
end
disp(d)
if ispc || ismac
s = xlswrite(char(pathexcelfile), d,1, 'L1');
else
csvwrite(strcat(pathexcelfile(1:end-4),'_out.csv'), d);
end
set(handles.simulationstatus,'String','Finished!');
% --- 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)
set(handles.convergentietext,'String','No');
set(handles.datapoint,'String','1');
set(handles.simulationstatus,'String','');
clear all
% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global pathexcelfile
Path = fullfile('~','Documents','Measurements');
[FileName,PathName,FilterIndex] = uigetfile(fullfile(Path,'*.xls'),'Select your Excel file');
if FilterIndex~=0
pathexcelfile=fullfile(PathName,FileName);
set(handles.edit1,'String',pathexcelfile);
end
3 Commenti
Adam
il 2 Set 2019
My point is still the same. In the function that yields the error message you define d as a cell array then try to assign a double to it.
Risposte (1)
Damian Renggli
il 8 Gen 2020
I have removed the bug, please check the latest version of the code (January2020).
I appologize for the inconvenience.
Damian
0 Commenti
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!