0% found this document useful (0 votes)
74 views5 pages

'Gui - Name' 'Gui - Singleton' 'Gui - Openingfcn' 'Gui - Outputfcn' 'Gui - Layoutfcn' 'Gui - Callback'

This document contains the code for a digital profilometer GUI application written in MATLAB. The code defines functions for opening and closing the GUI, reading sensor data from a serial port, plotting the sensor measurements, performing statistical analysis on the data, and writing the results to an Excel file. It also includes code to analyze the road profile measurements and determine the pavement condition level and recommended maintenance actions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
74 views5 pages

'Gui - Name' 'Gui - Singleton' 'Gui - Openingfcn' 'Gui - Outputfcn' 'Gui - Layoutfcn' 'Gui - Callback'

This document contains the code for a digital profilometer GUI application written in MATLAB. The code defines functions for opening and closing the GUI, reading sensor data from a serial port, plotting the sensor measurements, performing statistical analysis on the data, and writing the results to an Excel file. It also includes code to analyze the road profile measurements and determine the pavement condition level and recommended maintenance actions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

function varargout = Perfilometro Digital(varargin)

gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @Perfilometro_OpeningFcn, ...
'gui_OutputFcn', @Perfilometro_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 Perfilometro_OpeningFcn(hObject, eventdata, handles, varargin)


handles.output = hObject;
axes(handles.axes4)
handles.imagen=imread('logo2.bmp');
imagesc(handles.imagen)
axis off
guidata(hObject, handles);

function varargout = Perfilometro_OutputFcn(hObject, eventdata, handles)

varargout{1} = handles.output;

function tabla1_CellEditCallback(hObject, eventdata, handles)

function btn_ref_Callback(hObject, eventdata, handles)


%%
k = 13; %%Numero de intevalos
clear all;
clc;
pserial=serial('COM10','BaudRate',9600);
fopen(pserial);
figure('Name','Gráfica de valores obtenidos')
title('Perfil de superficie de rodadura');
xlabel('Muestra');
ylabel('Altura');
val=zeros(1,200);
jota = 1;
msj = 'Recibiendo...';
%%========Bloque de gráfica al recibir datos nuevos========
while jota <= 200
lectura = fscanf(pserial,'%d');
if lectura > 0
ylim([15 40.1]);
xlim([0 200.1]);
val(1,jota) = lectura;
hold on
plot(jota,val(1,jota),'x');
drawnow
jota = jota + 1;
else
set(handles.edit4,'string',msj)
end
end
grid;
A = val;
%%==============================================================
A1 = vec2mat(A,10);
set(handles.tabla1,'data',A1)
%%
minimo = min(A(1,:));
maximo = max(A(1,:));
rango = maximo - minimo;
amplitud = rango / k;
%%
A = sort(A);
N_1 = minimo;
N_2 = N_1 + amplitud;
N_3 = N_2 + amplitud;
N_4 = N_3 + amplitud;
N_5 = N_4 + amplitud;
N_6 = N_5 + amplitud;
N_7 = N_6 + amplitud;
N_8 = N_7 + amplitud;
N_9 = N_8 + amplitud;
N_10 = N_9 + amplitud;
N_11 = N_10 + amplitud;
N_12 = N_11+ amplitud;
N_13 = N_12 + amplitud;
N_14 = N_13 + amplitud;
count = zeros(1,13);
count(1,1) = numel(A(A(:)>=N_1 & A(:)<N_2));
count(1,2) = numel(A(A(:)>=N_2 & A(:)<N_3));
count(1,3) = numel(A(A(:)>=N_3 & A(:)<N_4));
count(1,4) = numel(A(A(:)>=N_4 & A(:)<N_5));
count(1,5) = numel(A(A(:)>=N_5 & A(:)<N_6));
count(1,6) = numel(A(A(:)>=N_6 & A(:)<N_7));
count(1,7) = numel(A(A(:)>=N_7 & A(:)<N_8));
count(1,8) = numel(A(A(:)>=N_8 & A(:)<N_9));
count(1,9) = numel(A(A(:)>=N_9 & A(:)<N_10));
count(1,10) = numel(A(A(:)>=N_10 & A(:)<N_11));
count(1,11) = numel(A(A(:)>=N_11 & A(:)<N_12));
count(1,12) = numel(A(A(:)>=N_12 & A(:)<N_13));
count(1,13) = numel(A(A(:)>=N_13 & A(:)<=N_14));
count_A = count;
%%
NR = zeros(1,180);
for i = 1:180
NR(1,i) = A(1,10+i);
end
count(1,1) = numel(NR(NR(:)>=N_1 & NR(:)<N_2));
count(1,2) = numel(NR(NR(:)>=N_2 & NR(:)<N_3));
count(1,3) = numel(NR(NR(:)>=N_3 & NR(:)<N_4));
count(1,4) = numel(NR(NR(:)>=N_4 & NR(:)<N_5));
count(1,5) = numel(NR(NR(:)>=N_5 & NR(:)<N_6));
count(1,6) = numel(NR(NR(:)>=N_6 & NR(:)<N_7));
count(1,7) = numel(NR(NR(:)>=N_7 & NR(:)<N_8));
count(1,8) = numel(NR(NR(:)>=N_8 & NR(:)<N_9));
count(1,9) = numel(NR(NR(:)>=N_9 & NR(:)<N_10));
count(1,10) = numel(NR(NR(:)>=N_10 & NR(:)<N_11));
count(1,11) = numel(NR(NR(:)>=N_11 & NR(:)<N_12));
count(1,12) = numel(NR(NR(:)>=N_12 & NR(:)<N_13));
count(1,13) = numel(NR(NR(:)>=N_13 & NR(:)<=N_14));
count_B = count;
axes(handles.axes1);
bar(count_A(:))
axes(handles.axes2);
bar(count_B(:))
count_C=zeros(1,13);
for i = 1:13
if (count_A(1,i) == 0)
count_C(1,i) = 0;
else
count_C(1,i) = count_B(1,i) / count_A(1,i);
end;
end;
D = 5*(count_C(1,1) + count_C(1,2) + count_C(1,3) + count_C(1,4) +
count_C(1,5) + count_C(1,6) + count_C(1,7) + count_C(1,8) + count_C(1,9)
+ count_C(1,10) + count_C(1,11) + count_C(1,12) + count_C(1,13));

if D >= 42
v1 = 3;
else
v1 = 2;
end;
switch v1
case 2
IRI = 0.0485*D;
T1 = importdata('IRI_2.txt');
set(handles.edit2,'string',T1)
case 3
IRI = 0.593 + 0.0471*D;
T1 = importdata('IRI_1.txt');
set(handles.edit2,'string',T1)
end
%%here
set(handles.edit1,'string',D)
set(handles.edit3,'string',IRI)
%%
%Creación de Excel
filename = 'Resultados.xlsx';
Titulo1 = {'Mediciones'};
sheet = 1;
xlRange = 'A1';
xlswrite(filename,Titulo1,sheet,xlRange)
xlRange = 'A2';
xlswrite(filename,transpose(A),sheet,xlRange)

Titulo2= {'Distribución de frecuencia Total'};


sheet = 2;
xlRange = 'C1';
xlswrite(filename,Titulo2,sheet,xlRange)
xlRange = 'B2';
rangos = {'Rangos',N_2, N_3, N_4, N_5, N_6, N_7, N_8, N_9, N_10, N_11,
N_12, N_13, N_14};
xlswrite(filename,rangos,sheet,xlRange)
xlRange = 'C3';
xlswrite(filename,count_A,sheet,xlRange)

Titulo3 = {'Distribución de frecuencia discriminada'};


xlRange = 'C6';
xlswrite(filename,Titulo3,sheet,xlRange)
xlRange = 'B7';
rangos = {'Rangos',N_2, N_3, N_4, N_5, N_6, N_7, N_8, N_9, N_10, N_11,
N_12, N_13, N_14};
xlswrite(filename,rangos,sheet,xlRange)
xlRange = 'C8';
xlswrite(filename,count_B,sheet,xlRange)

Out = {'D', D; 'IRI',IRI};


xlRange = 'C10';
xlswrite(filename,Out,sheet,xlRange)

if IRI <= 1.48


h = msgbox({'Estado del Pavimento:' ' ' '
Bueno.' ' ' 'Acción recomendada:' ' ' '
No necesaria.' ' '},'Analisis');
elseif IRI <= 2.70
h = msgbox({'Estado del Pavimento:' ' ' '
Regular.' ' ' 'Acción recomendada:' ' ' '
Tratamiento superficial.' ' '},'Analisis');
elseif IRI > 2.70
h = msgbox({'Estado del Pavimento:' ' ' '
Muy Malo.' ' ' 'Acción recomendada:' ' ' '
Reconstrucción del tramo de vía.' ' '},'Analisis');
end;
%%
fclose(pserial);
delete(pserial);
function edit1_Callback(hObject, eventdata, handles)

function edit1_CreateFcn(hObject, eventdata, handles)

if ispc && isequal(get(hObject,'BackgroundColor'),


get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function edit2_Callback(hObject, eventdata, handles)

function edit2_CreateFcn(hObject, eventdata, handles)

if ispc && isequal(get(hObject,'BackgroundColor'),


get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit3_Callback(hObject, eventdata, handles)

function edit3_CreateFcn(hObject, eventdata, handles)

if ispc && isequal(get(hObject,'BackgroundColor'),


get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function pushbutton2_Callback(hObject, eventdata, handles)

close all;

function edit4_Callback(hObject, eventdata, handles)

function edit4_CreateFcn(hObject, eventdata, handles)

if ispc && isequal(get(hObject,'BackgroundColor'),


get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

You might also like