if true % code
end a program on the Newton Rhapson method in GUI.if truefunction varargout = untitled(varargin)% UNTITLED M-file for untitled.fig
% UNTITLED, by itself, creates a new UNTITLED or raises the existing
% singleton*.
%
% H = UNTITLED returns the handle to a new UNTITLED or the handle to
% the existing singleton*.
%% UNTITLED('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in UNTITLED.M with the given input arguments.
%% UNTITLED('Property','Value',...) creates a new UNTITLED or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before untitled_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to untitled_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 untitled
% Last Modified by GUIDE v2.5 27-Jul-2015 13:52:31
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @untitled_OpeningFcn, ... 'gui_OutputFcn', @untitled_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []);if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1});endif 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 untitled is made visible.
function untitled_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 untitled (see VARARGIN)
% Choose default command line output for untitled
handles.output = hObject;% Update handles structure
guidata(hObject, handles);% UIWAIT makes untitled wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = untitled_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 xini_Callback(hObject, eventdata, handles)% hObject handle to xini (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 xini as text
% str2double(get(hObject,'String')) returns contents of xini as a double
% --- Executes during object creation, after setting all properties.
function xini_CreateFcn(hObject, eventdata, handles)% hObject handle to xini (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');endfunction tolerancia_Callback(hObject, eventdata, handles)% hObject handle to tolerancia (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 tolerancia as text
% str2double(get(hObject,'String')) returns contents of tolerancia as a double
% --- Executes during object creation, after setting all properties.function tolerancia_CreateFcn(hObject, eventdata, handles)% hObject handle to tolerancia (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');endfunction funcion_Callback(hObject, eventdata, handles)% hObject handle to funcion (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 funcion as text
% str2double(get(hObject,'String')) returns contents of funcion as a double
% --- Executes during object creation, after setting all properties.function funcion_CreateFcn(hObject, eventdata, handles)% hObject handle to funcion (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');endfunction raiz_Callback(hObject, eventdata, handles)% hObject handle to raiz (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 raiz as text
% str2double(get(hObject,'String')) returns contents of raiz as a double
% --- Executes during object creation, after setting all properties.function raiz_CreateFcn(hObject, eventdata, handles)% hObject handle to raiz (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 selection change in seleccionar.
function seleccionar_Callback(hObject, eventdata, handles)% hObject handle to seleccionar (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)format long gf=get(handles.funcion,'string');xi=get(handles.xini,'string');Es=get(handles.tolerancia,'string');xi=str2double(xi);Es=str2double(Es);syms xdf=diff(f);df=inline('df');ddf=diff(f,2);ddf=inline('ddf');f=inline(f);i=1;Ea(1)=100;xi1=x1;v=get(handles.seleccionar,'value');switch v case 2 while abs(Ea>=Es) fxi=feval(f,xi); dfxi=feval(df,xi); xi1= xi -(fxi/dfxi); Ea=abs((xi1-xi)/(xi1)*100); xi=xi1; i=i+1; end h=num2str(xi1); set(handles.raiz,'string',h); c=str3double(h); fplot(handles.grafica,f,[(c-5) (c+5)]); case 3 while abs(Ea>=Es) fxi=feval(f,xi); dfxi=feval(df,xi); ddfxi=feval(ddf,xi); xi1= xi -((fxi*dfxi)/((dfxi)^2-fxi*ddfxi)); Ea=abs(((xi1-xi)/xi1)*100); xi=xi1; i=i+1; end h=num2str(xi1); set(handles.raiz,'string',h); c=str3double(h); fplot(handles.grafica,f,[(c-5) (c+5)]);end% Hints: contents = cellstr(get(hObject,'String')) returns seleccionar contents as cell array
% contents{get(hObject,'Value')} returns selected item from seleccionar
% --- Executes during object creation, after setting all properties.function seleccionar_CreateFcn(hObject, eventdata, handles)% hObject handle to seleccionar (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 Untitled_1_Callback(hObject, eventdata, handles)% hObject handle to Untitled_1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% --------------------------------------------------------------------function ayuda_Callback(hObject, eventdata, handles)% hObject handle to ayuda (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% --------------------------------------------------------------------function acercade_Callback(hObject, eventdata, handles)% hObject handle to acercade (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)acercade% --------------------------------------------------------------------function insttrucciones_Callback(hObject, eventdata, handles)% hObject handle to insttrucciones (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)instrucciones% --------------------------------------------------------------------function borrar_Callback(hObject, eventdata, handles)% hObject handle to borrar (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)set(handles.funcion,'string','');set(handles.xini,'string','');set(handles.tolerancia,'string','');set(handles.raiz,'string','');set(handles.advertir,'string','');% --------------------------------------------------------------------function salir_Callback(hObject, eventdata, handles)% hObject handle to salir (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)closeError:??? Error using ==> fevalUndefined function or method 'pushbutton1_CreateFcn' for inputarguments of type 'double'.Error in ==> gui_mainfcn at 96 feval(varargin{:});Error in ==> untitled at 42 gui_mainfcn(gui_State, varargin{:});Error in ==>@(hObject,eventdata)untitled('pushbutton1_CreateFcn',hObject,eventdata,guidata(hObject))??? Error using ==> struct2handleError while evaluating uicontrol CreateFcn??? Error using ==> function seleccionar_CreateFcn(hObject,eventdata, handles)Error: Function definitions are not permitted at the prompt orin scripts.??? Error using ==> struct2handleError while evaluating uipanel CreateFcn
I need for it to calculate this equation .
sqrt(5*x+2)-x
and automatic calculate the derivative.
end
Best Answer