Matlab - Graficar con datos generados en una GUI

 
Vista:
sin imagen de perfil

Graficar con datos generados en una GUI

Publicado por Ronald (4 intervenciones) el 02/06/2017 03:53:27
Buenas noches estimados;

En esta oportunidad les solicito apoyo para solventar una duda que tengo.

Tengo una GUI, mendiante la cual se ingrensan una serie de datos. Con estos datos se obtiene una serie de resultados que se pueden arreglar en varios vectores. Deseo que luego del pushbutton y de ejecutado los calculos pertienentes, se aperturara una grafica en un plano cartesiano graficando los datos que tengo agrupado en los vectores anteriormente dichos.

Agradezco de antemano la ayuda que me puedan prestar.

Saludos.

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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
function uibuttongroup6_SelectionChangeFcn(hObject, eventdata, handles)
if(strcmp(get(eventdata.NewValue,'Tag'),'radiobutton7'))
    set(handles.edit7,'Enable','off')
    set(handles.edit8,'Enable','off')
    z=1;
else
    set(handles.edit7,'String',num2str(0));
    set(handles.edit8,'String',num2str(0));
    set(handles.edit7,'Enable','on');
    set(handles.edit8,'Enable','on');
    z=0;
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)
 
%Par?metros fijos
To=293.15;  %Temperatura del aire estandar en grados Kelvin
f = xlsread('parametros','Hoja1','A2:A27');
CaP = xlsread('parametros','Hoja1','B2:B27');
CbP = xlsread('parametros','Hoja1','C2:C27');
CaC = xlsread('parametros','Hoja1','D2:D27');
CbC = xlsread('parametros','Hoja1','E2:E27');
Cero = xlsread('parametros','Hoja1','F2:F27');
Uno = xlsread('parametros','Hoja1','G2:G27');
dBA = xlsread('parametros','Hoja1','H2:H27');
 
longitud= str2double(get(handles.edit1,'String'));
velocidad = str2double(get(handles.edit2,'String'));
distancia = str2double(get(handles.edit3,'String'));
hm = str2double(get(handles.edit4,'String'));
temperatura = str2double(get(handles.edit5,'String'));
humedad = str2double(get(handles.edit6,'String'));
barrera1 = str2double(get(handles.edit7,'String'));
barrera2 = str2double(get(handles.edit8,'String'));
 
%Calculo para nivel de potencia sonora por roce aerodinamico
if velocidad>=0 && velocidad<=98
    La=Cero;
    xlswrite('parametros.xls', La, 'Hoja2','B2:B27');
else
    if velocidad>=99 && velocidad<=200
        aero=96*log10(velocidad/200)+67;
        La=aero*Uno;
        xlswrite('parametros.xls', La, 'Hoja2','B2:B27');
    else
        if velocidad>=201 && velocidad<=406
            aero=64*log10(velocidad/100)+60;
            La=aero*Uno;
            xlswrite('parametros.xls', La, 'Hoja2','B2:B27');
        end
    end
end
 
%Calculo para nivel de potencia sonora por contacto rueda riel 
x = get(handles.radiobutton1,'Value');
if x==1
    Lw1m=CaP*log10(velocidad/100)+CbP;
    Lw=Lw1m+10*log10(longitud);
    xlswrite('parametros.xls', Lw, 'Hoja2','A2:A27');
else
    Lw1m=CaC*log10(velocidad/100)+CbC;
    Lw=Lw1m+10*log10(longitud);
    xlswrite('parametros.xls', Lw, 'Hoja2','A2:A27');
end
 
%Calculo de atenuacion por presencia de vegetacion
y = get(handles.radiobutton3,'Value');
if y==1
    Avegetacion=Cero;
    xlswrite('parametros.xls', Avegetacion, 'Hoja2','C2:C27');
else
    y = get(handles.radiobutton4,'Value');
    if y==1
        Avegetacion=(0.18*log10(f)-0.31)*distancia;
        xlswrite('parametros.xls', Avegetacion, 'Hoja2','C2:C27');
    else
        Avegetacion=0.01*f.^(-1/3)*distancia;
        xlswrite('parametros.xls', Avegetacion, 'Hoja2','C2:C27');
    end
end
 
%Calculo de atenuacion por barrera
w = get(handles.radiobutton6,'Value');
if w==1
    N=(2*(barrera1+barrera2-distancia))./f;
    Abarrera=20*log10((sqrt((2*pi)./N))./(tanh(sqrt((2*pi)./N))))+5;
    xlswrite('parametros.xls', Abarrera, 'Hoja2','D2:D27');
else
    Abarrera=Cero;
    xlswrite('parametros.xls', Abarrera, 'Hoja2','D2:D27');
end
 
%Calculo de atenuacion por suelo
suelo=4.8-((2*hm)/distancia)*(17+300/distancia);
Asuelo=suelo*Uno;
xlswrite('parametros.xls', Asuelo, 'Hoja2','E2:E27');
 
%Calculo de atenuacion por edificios
Aedificio=Cero;
xlswrite('parametros.xls', Aedificio, 'Hoja2','F2:F27');
 
%Calculo de propagacion sonora debido a la divergencia geometrica
Adiv=10*log10(4*pi*distancia)*Uno;
xlswrite('parametros.xls', Adiv, 'Hoja2','G2:G27');
 
%Calculo de indice de directividad
Vson=350; %Velocidad del sonido en m/s a 20 grados centigrados
DI=10*log10((2*longitud*f)/Vson);
xlswrite('parametros.xls', DI, 'Hoja2','H2:H27');
 
%Calculo de coeficiente de atenuacion debido a la absorcion atmosferica
Fro=24+4.04*10^4*humedad*((0.02+humedad)/(0.391+humedad));
Frn=(temperatura/To)^(1/2)*(9+280*humedad*exp(-4.17*(temperatura/To)^(-1/3)-1));
alfa=869*f.^2.*(1.84*10^(-11)*(temperatura/To)^(1/2)+(temperatura/To)^(-5/2)*(0.01275*(exp(-2239.1/temperatura)./(Fro+(f.^2/Fro)))+0.1068*(exp(-3352/temperatura)./(Frn+(f.^2/Frn)))));
Aabs=alfa*distancia/100;
xlswrite('parametros.xls', Aabs, 'Hoja2','I2:I27');
 
%Nivel de presion sonora en dB 
Lp=10*log10(10.^(Lw/10)-10.^(Adiv/10)+10.^(DI/10)-10.^(11/10)-10.^(Avegetacion/10)-10.^(Asuelo/10)-10.^(Aedificio/10)-10.^(Aabs/10)-10.^(Abarrera/10));
xlswrite('parametros.xls', Lp, 'Hoja2','J2:J27');
 
%Nivel de presion sonora en dB con La
Lpaero=10*log10(10.^(Lw/10)+10.^(La/10)-10.^(Adiv/10)+10.^(DI/10)-10.^(11/10)-10.^(Avegetacion/10)-10.^(Abarrera/10)-10.^(Asuelo/10)-10.^(Aedificio/10)-10.^(Aabs/10));
xlswrite('parametros.xls', Lpaero, 'Hoja2','K2:K27');
 
%Nivel de presi?n sonora en dBA
Lpa=Lp+dBA;
xlswrite('parametros.xls', Lpa, 'Hoja2','L2:L27');
 
%Nivel de presion sonora en dBA con Lpaero
Lpaaero=Lpaero+dBA;
xlswrite('parametros.xls', Lpaaero, 'Hoja2','M2:M27');
 
%Nivel de presion son;ora ponderada en pascales
Lpp=2*10.^(-5+Lpa/20);
xlswrite('parametros.xls', Lpp, 'Hoja2','N2:N27');
 
%Nivel de presion sonora sin ponderar en pascales 
Lpb=2*10.^(-5+Lp/20);
xlswrite('parametros.xls', Lpb, 'Hoja2','O2:O27');
 
%Calculo de nivel de presion sonora general en decibelios lineales
Lpg1=10.^(Lp/10);
Lpg2=sum(Lpg1);
Lpg=10*log10(Lpg2);
 
%Calculo de nivel de presion sonora general en decibelios lineales
Lpga1=10.^(Lpa/10);
Lpga2=sum(Lpga1);
Lpga=10*log10(Lpga2);
 
winopen( 'parametros.xls' );
 
Y=(Lw);
plot1(Y,f);
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de JOSE JEREMIAS CABALLERO
Val: 6.975
Oro
Ha mantenido su posición en Matlab (en relación al último mes)
Gráfica de Matlab

Graficar con datos generados en una GUI

Publicado por JOSE JEREMIAS CABALLERO (5917 intervenciones) el 02/06/2017 16:09:57
Debería subir tanto su archivo fig, su archivo m y su archivo excel, segun viendo a grandes rasgos Y=(Lw) este es un numero y no un vector y allí estaria uno de los problemas.

Saludos
JOSE JEREMIAS CABALLERO
Asesor de Proyectos con Matlab
Servicios de programación matlab


http://matlabcaballero.blogspot.com
https://www.facebook.com/matlabcaballero/
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil

Graficar con datos generados en una GUI

Publicado por Ronald (4 intervenciones) el 03/06/2017 02:54:29
Esto es lo que intento hacer, disculpe los errores de novatos, pero es que soy novato!!!

Saludos.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar