Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
Need assistance error im getting from GUI
조회 수: 2 (최근 30일)
이전 댓글 표시
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)
diffyEQ = solution(x1);
set(handles.solution, 'String', char(diffyEQ));
function diffyEQ=solution(x1)
syms t y(t)
x1=10*exp(-3*t)
x=diff(x1)
Dy = diff(y);
D2y = diff(y,2);
diffyEQ = dsolve(D2y+3*Dy+2*y == x, y(0) == 0, Dy(0) == -5)
Here are my errors
Undefined function or variable 'x1'.
Error in diffyQ>pushbutton1_Callback (line 103)
diffyEQ = solution(x1);
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.
댓글 수: 0
답변 (1개)
Walter Roberson
2018년 4월 13일
You are calling
diffyEQ = solution(x1);
when you have not assigned anything to x1.
However it is not clear why you are bothering to pass anything to solution(), since inside that routine you have
x1=10*exp(-3*t)
which would overwrite whatever parameter was passed anyhow.
댓글 수: 0
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!