-
Notifications
You must be signed in to change notification settings - Fork 0
/
derivadaIndefinida.m
120 lines (95 loc) · 3.7 KB
/
derivadaIndefinida.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
function varargout = derivadaIndefinida(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @derivadaIndefinida_OpeningFcn, ...
'gui_OutputFcn', @derivadaIndefinida_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
function derivadaIndefinida_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
guidata(hObject, handles);
function varargout = derivadaIndefinida_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
function Calcular_Callback(hObject, eventdata, handles)
syms x;
% Obtener la función ingresada por el usuario desde el cuadro de texto
f_str = str2sym(get(handles.txtFun, 'string'));
% f = str2sym(get(handles.txtFun,'string'));
% Convertir la cadena de caracteres a una expresión simbólica
% Definir la variable simbólica
% Calcular la derivada de la expresión simbólica
der = diff(f_str, x);
% Mostrar la derivada numérica en el cuadro de texto txt_resfun
set(handles.txt_resfun, 'string', char(der));
% Calcular la derivada con formato pretty
outstr = evalc('pretty(der)');
% Mostrar la derivada con formato en el cuadro de texto txtRes
set(handles.txtRes, 'string', outstr);
function limpiar_Callback(hObject, eventdata, handles)
set(handles.txtFun,'string','');
set(handles.txtRes,'string','');
set(handles.txt_resfun,'string','');
cla(handles.graficar);
function txtRes_Callback(hObject, eventdata, handles)
function txtRes_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function txtFun_Callback(hObject, eventdata, handles)
function txtFun_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function radiobutton1_Callback(hObject, eventdata, handles)
function radiobutton2_Callback(hObject, eventdata, handles)
function pushbutton3_Callback(hObject, eventdata, handles)
syms x;
opc=get(handles.selector,'value');
switch opc
case 1
axes(handles.graficar);
bar(0);
case 2
y=eval(get(handles.txtFun,'string'));
axes(handles.graficar);
ezplot(y);
case 3
y=eval(get(handles.txtFun,'string'));
syms x;
deri=diff(y,x);
axes(handles.graficar);
ezplot(deri);
case 4
y=eval(get(handles.txtFun,'string'));
y1=eval(get(handles.txtFun,'string'));
syms x;
deri=diff(y,x);
hold on
axes(handles.graficar);
ezplot(deri);
ezplot(y1);
xlabel('Eje X');
ylabel('Eje Y');
hold off
end
function pushbutton4_Callback(hObject, eventdata, handles)
close(gcbf);
function selector_Callback(hObject, eventdata, handles)
function selector_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function txt_resfun_Callback(hObject, eventdata, handles)
function txt_resfun_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end