Vous êtes sur la page 1sur 13

ESCUELA MILITAR DE INGENIERÍA

MCAL. ANTONIO JOSE DE SUCRE

MACROS Y GUIDE
TRATAMIENTO DE ERRORES

1. MACROS (EXCEL)

DATOS DE LAS TRES MESAS CON SUS RESPECTIVAS MEDIDAS:

MESA 1
No. NOMBRES A B C D
1 MELISA 73 46 51,3 47
2 ENRIQUE 72 48 52 45
3 VALERIA 72 46 59 47
4 MASSIEL 70 45 51,2 44,7
YECIT tu salvador
5
70 44,7 51,2 45,1

JONATHAN MARTIN PINTO MAYTA – 4A 1


ESCUELA MILITAR DE INGENIERÍA
MCAL. ANTONIO JOSE DE SUCRE

MESA 2
No. NOMBRES A B C D
1 Gerardo 70 45,4 51,5 45
2 Alisson 70 45,5 51,5 45
3 Tania 70 45 51 45,1
4 Jhoselin 70,1 45,5 51,6 45,1
5 Wara 70,2 45,5 51,5 45
6 Alférez 70 45,5 51,9 45,8
7 Mauricio 70,4 45,7 51,8 45,6
8 Jonathan 70 45,5 51,6 45

MESA 3
No. NOMBRES A B C D
1 JHESICA 69,8 51,2 50,5 50,9
2 KAREN 69,5 50,8 50 50,8
3 DUMA 69,7 50,9 50,5 50,9
4 BRAYAN 69,5 50,5 50 50,8

A continuación, se muestran los datos estadísticos respectivos para el tratamiento de errores:

MESA 1
A B C D
MEDIA ARITMÉTICA 71,400 45,940 52,940 45,760
MEDIA GEOMÉTRICA 71,390 45,926 52,857 45,749
MEDIA ARMÓNICA 71,380 45,911 52,778 45,737
VARIANZA 1,800 1,668 11,588 1,303
DESVIACIÓN ESTÁNDAR 1,342 1,292 3,404 1,141
ERROR 0,600 0,578 1,522 0,510
MESA 2
A B C D
MEDIA ARITMÉTICA 70,088 45,450 51,550 45,200
MEDIA GEOMÉTRICA 70,087 45,450 51,549 45,199
MEDIA ARMÓNICA 70,087 45,449 51,549 45,198
VARIANZA 0,021 0,040 0,071 0,100
DESVIACIÓN ESTÁNDAR 0,146 0,200 0,267 0,316
ERROR 0,052 0,071 0,094 0,112

JONATHAN MARTIN PINTO MAYTA – 4A 2


ESCUELA MILITAR DE INGENIERÍA
MCAL. ANTONIO JOSE DE SUCRE

MESA 3

A B C D
MEDIA ARITMÉTICA 69,625 50,850 50,250 50,850
MEDIA GEOMÉTRICA 69,625 50,849 50,249 50,850
MEDIA ARMÓNICA 69,625 50,849 50,249 50,850
VARIANZA 0,022 0,083 0,083 0,003
DESVIACIÓN ESTÁNDAR 0,150 0,289 0,289 0,058
ERROR 0,075 0,144 0,144 0,029

Para mantener los datos correctos y todas las fórmulas, se guardó en un macro:
Sub Macro_1_ESTADISTICOS ()
' Macro_1_ESTADISTICOS Macro
' CÁLCULO DE DATOS ESTADÍSTICOS
' Acceso directo: Ctrl+Mayús+D
'
ActiveCell.FormulaR1C1 = "=AVERAGE(R[1]C[-6]:R[5]C[-6])"
Range("J5").Select
Selection.AutoFill Destination:=Range("J5:M5"), Type:=xlFillDefault
Range("J5:M5").Select
Range("J6").Select
ActiveCell.FormulaR1C1 = "=GEOMEAN(RC[-6]:R[4]C[-6])"
Range("J6").Select
Selection.AutoFill Destination:=Range("J6:M6"), Type:=xlFillDefault
Range("J6:M6").Select
Selection.NumberFormat = "0.000"
Range("J7").Select
ActiveCell.FormulaR1C1 = "=HARMEAN(R[-1]C[-6]:R[3]C[-6])"
Range("J7").Select
Selection.AutoFill Destination:=Range("J7:M7"), Type:=xlFillDefault
Range("J7:M7").Select

JONATHAN MARTIN PINTO MAYTA – 4A 3


ESCUELA MILITAR DE INGENIERÍA
MCAL. ANTONIO JOSE DE SUCRE

Selection.NumberFormat = "0.000"
Range("J8").Select
ActiveCell.FormulaR1C1 = "=VAR(R[-2]C[-6]:R[2]C[-6])"
Range("J8").Select
Selection.AutoFill Destination:=Range("J8:M8"), Type:=xlFillDefault
Range("J8:M8").Select
Range("J9").Select
ActiveCell.FormulaR1C1 = "=STDEVA(R[-3]C[-6]:R[1]C[-6])"
Range("J9").Select
Selection.AutoFill Destination:=Range("J9:M9"), Type:=xlFillDefault
Range("J9:M9").Select
Selection.NumberFormat = "0.000"
Range("J10").Select
ActiveCell.FormulaR1C1 = "=R[-1]C/SQRT(R10C2)"
Range("J10").Select
Selection.AutoFill Destination:=Range("J10:M10"), Type:=xlFillDefault
Range("J10:M10").Select
Selection.NumberFormat = "0.000"
Range("K12").Select
End Sub

JONATHAN MARTIN PINTO MAYTA – 4A 4


ESCUELA MILITAR DE INGENIERÍA
MCAL. ANTONIO JOSE DE SUCRE

2. GUIDE (MATLAB)
function varargout = untitled(varargin)
% UNTITLED MATLAB code 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 05-Aug-2019 22:29:26

% 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});
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 untitled is made visible.


function untitled_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.

JONATHAN MARTIN PINTO MAYTA – 4A 5


ESCUELA MILITAR DE INGENIERÍA
MCAL. ANTONIO JOSE DE SUCRE

% 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 dato1_Callback(hObject, eventdata, handles)


% hObject handle to dato1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global A;
A=str2double(get(hObject,'String'));
% Hints: get(hObject,'String') returns contents of dato1 as text
% str2double(get(hObject,'String')) returns contents of dato1 as a
double

% --- Executes during object creation, after setting all properties.


function dato1_CreateFcn(hObject, eventdata, handles)
% hObject handle to dato1 (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

JONATHAN MARTIN PINTO MAYTA – 4A 6


ESCUELA MILITAR DE INGENIERÍA
MCAL. ANTONIO JOSE DE SUCRE

function dato2_Callback(hObject, eventdata, handles)


% hObject handle to dato2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global B;
B=str2double(get(hObject,'String'));
% Hints: get(hObject,'String') returns contents of dato2 as text
% str2double(get(hObject,'String')) returns contents of dato2 as a
double

% --- Executes during object creation, after setting all properties.


function dato2_CreateFcn(hObject, eventdata, handles)
% hObject handle to dato2 (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

function dato3_Callback(hObject, eventdata, handles)


% hObject handle to dato3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global C;
C=str2double(get(hObject,'String'));
% Hints: get(hObject,'String') returns contents of dato3 as text
% str2double(get(hObject,'String')) returns contents of dato3 as a
double

% --- Executes during object creation, after setting all properties.


function dato3_CreateFcn(hObject, eventdata, handles)
% hObject handle to dato3 (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

function dato4_Callback(hObject, eventdata, handles)

JONATHAN MARTIN PINTO MAYTA – 4A 7


ESCUELA MILITAR DE INGENIERÍA
MCAL. ANTONIO JOSE DE SUCRE

% hObject handle to dato4 (see GCBO)


% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global D;
D=str2double(get(hObject,'String'));
% Hints: get(hObject,'String') returns contents of dato4 as text
% str2double(get(hObject,'String')) returns contents of dato4 as a
double

% --- Executes during object creation, after setting all properties.


function dato4_CreateFcn(hObject, eventdata, handles)
% hObject handle to dato4 (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

function dato5_Callback(hObject, eventdata, handles)


% hObject handle to dato5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global E;
E=str2double(get(hObject,'String'));
% Hints: get(hObject,'String') returns contents of dato5 as text
% str2double(get(hObject,'String')) returns contents of dato5 as a
double

% --- Executes during object creation, after setting all properties.


function dato5_CreateFcn(hObject, eventdata, handles)
% hObject handle to dato5 (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

function dato6_Callback(hObject, eventdata, handles)


% hObject handle to dato6 (see GCBO)

JONATHAN MARTIN PINTO MAYTA – 4A 8


ESCUELA MILITAR DE INGENIERÍA
MCAL. ANTONIO JOSE DE SUCRE

% eventdata reserved - to be defined in a future version of MATLAB


% handles structure with handles and user data (see GUIDATA)
global F;
F=str2double(get(hObject,'String'));
% Hints: get(hObject,'String') returns contents of dato6 as text
% str2double(get(hObject,'String')) returns contents of dato6 as a
double

% --- Executes during object creation, after setting all properties.


function dato6_CreateFcn(hObject, eventdata, handles)
% hObject handle to dato6 (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

function dato7_Callback(hObject, eventdata, handles)


% hObject handle to dato7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global G;
G=str2double(get(hObject,'String'));
% Hints: get(hObject,'String') returns contents of dato7 as text
% str2double(get(hObject,'String')) returns contents of dato7 as a
double

% --- Executes during object creation, after setting all properties.


function dato7_CreateFcn(hObject, eventdata, handles)
% hObject handle to dato7 (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

function dato8_Callback(hObject, eventdata, handles)


% hObject handle to dato8 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB

JONATHAN MARTIN PINTO MAYTA – 4A 9


ESCUELA MILITAR DE INGENIERÍA
MCAL. ANTONIO JOSE DE SUCRE

% handles structure with handles and user data (see GUIDATA)


global H;
H=str2double(get(hObject,'String'));
% Hints: get(hObject,'String') returns contents of dato8 as text
% str2double(get(hObject,'String')) returns contents of dato8 as a
double

% --- Executes during object creation, after setting all properties.


function dato8_CreateFcn(hObject, eventdata, handles)
% hObject handle to dato8 (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 promedio.


function promedio_Callback(hObject, eventdata, handles)
% hObject handle to promedio (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global A;
global B;
global C;
global D;
global E;
global F;
global G;
global H;
X=(A+B+C+D+E+F+G+H)/8
set(handles.resultado1,'string',X);

% --- Executes on button press in geometrica.


function geometrica_Callback(hObject, eventdata, handles)
% hObject handle to geometrica (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global A;
global B;
global C;
global D;
global E;
global F;
global G;
global H;
G=(A+B+C+D+E+F+G+H)^(1/8)
set(handles.resultado2,'string',G);

% --- Executes on button press in aritmetica.

JONATHAN MARTIN PINTO MAYTA – 4A 10


ESCUELA MILITAR DE INGENIERÍA
MCAL. ANTONIO JOSE DE SUCRE

function aritmetica_Callback(hObject, eventdata, handles)


% hObject handle to aritmetica (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global A;
global B;
global C;
global D;
global E;
global F;
global G;
global H;
X=(8)/((A^-1)+(B^-1)+(C^-1)+(D^-1)+(D^-1)+(E^-1)+(F^-1)+(G^-1))
set(handles.resultado3,'string',X);

% --- Executes on button press in varianza.


function varianza_Callback(hObject, eventdata, handles)
% hObject handle to varianza (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global A;
global B;
global C;
global D;
global E;
global F;
global G;
global H;
R=(A+B+C+D+E+F+G+H)/8;
T=(((A-R).^2)+((B-R).^2)+((C-R).^2)+((D-R).^2)+((E-R).^2)+((F-R).^2)+((G-
R).^2));
Var=T/7
set(handles.resultado4,'string',Var);

% --- Executes on button press in desviacion.


function desviacion_Callback(hObject, eventdata, handles)
% hObject handle to desviacion (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global A;
global B;
global C;
global C;
global D;
global E;
global F;
global G;
U=(A+B+C+D+E+F+G)/8;
T=(((A-U).^2)+((B-U).^2)+((C-U).^2)+((D-U).^2)+((E-U).^2)+((F-U).^2)+((G-
U).^2)+((H-U).^2));
M=T/7;
DE=(M)^(1/2)
set(handles.resultado5,'string',DE);

% --- Executes on button press in limpiar.


function limpiar_Callback(hObject, eventdata, handles)

JONATHAN MARTIN PINTO MAYTA – 4A 11


ESCUELA MILITAR DE INGENIERÍA
MCAL. ANTONIO JOSE DE SUCRE

set(handles.dato1,'string','');
set(handles.dato2,'string','');
set(handles.dato3,'string','');
set(handles.dato4,'string','');
set(handles.dato5,'string','');
set(handles.dato6,'string','');
set(handles.dato7,'string','');
set(handles.dato8,'string','');
set(handles.resultado1,'string','');
set(handles.resultado2,'string','');
set(handles.resultado3,'string','');
set(handles.resultado4,'string','');
set(handles.resultado5,'string','');
% hObject handle to limpiar (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% --- Executes on button press in cerrar.


function cerrar_Callback(hObject, eventdata, handles)
close(gcbf)
% hObject handle to cerrar (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

>> untitled

X=

JONATHAN MARTIN PINTO MAYTA – 4A 12


ESCUELA MILITAR DE INGENIERÍA
MCAL. ANTONIO JOSE DE SUCRE

70.0875

G=

2.2059

X=

70.0872

Var =

0.0212

Desv =

0.1458

JONATHAN MARTIN PINTO MAYTA – 4A 13

Vous aimerez peut-être aussi