Hey can you please help me with these errors im getting from my GUI

1 visualizzazione (ultimi 30 giorni)
function varargout = diffyQ(varargin)
% DIFFYQ MATLAB code for diffyQ.fig
% DIFFYQ, by itself, creates a new DIFFYQ or raises the existing
% singleton*.
%
% H = DIFFYQ returns the handle to a new DIFFYQ or the handle to
% the existing singleton*.
%
% DIFFYQ('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in DIFFYQ.M with the given input arguments.
%
% DIFFYQ('Property','Value',...) creates a new DIFFYQ or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before diffyQ_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to diffyQ_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 diffyQ
% Last Modified by GUIDE v2.5 12-Apr-2018 12:08:25
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @diffyQ_OpeningFcn, ...
'gui_OutputFcn', @diffyQ_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 diffyQ is made visible.
function diffyQ_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 diffyQ (see VARARGIN)
% Choose default command line output for diffyQ
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes diffyQ wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = diffyQ_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;
function input_Callback(hObject, eventdata, handles)
% hObject handle to input (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 input as text
% str2double(get(hObject,'String')) returns contents of input as a double
% --- Executes during object creation, after setting all properties.
function input_CreateFcn(hObject, eventdata, handles)
% hObject handle to input (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)
x= str2double(get(handles.input,'string'));
diffyEQ = solve(x);
num2str(set(handles.solution, 'string', diffyEQ));
function diffyEQ = solve(x)
syms t;
x2=diff(x);
diffyEQ = dsolve('(D2y)+(3*Dy)+(2*y)= x2', 'Dy(0) = -5 ','y(0) = 0');
pretty(diffyEQ)
These are my errors
Error while evaluating UIControl Callback.
x2 / x2 \
-- - exp(-t) (x2 + 5) + exp(-2 t) | -- + 5 |
2 \ 2 /
Error using matlab.ui.control.UIControl/set
Error setting property 'String' of class 'UIControl':
Value must be a character array, numeric array, or cell array.
Error in diffyQ>pushbutton1_Callback (line 105)
num2str(set(handles.solution, 'string', diffyEQ));
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in diffyQ (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)diffyQ('pushbutton1_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback.

Risposta accettata

Walter Roberson
Walter Roberson il 12 Apr 2018
Change
num2str(set(handles.solution, 'string', diffyEQ));
to
set(handles.solution, 'String', char(diffyEQ));

Più risposte (0)

Categorie

Scopri di più su Migrate GUIDE Apps in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by