%% graficos 1D clearvars; close all; clc; %este programa se centrara en los distintos tipos de graficos usando arreglos %% caso 01 no hay prelocalizacion for n = 1:101 t(n) = (n-1)/10; ft1(n) = 2*sin(2*pi*t(n)/10); ft2(n) = log(t(n) + 1)/(t(n) + 1); ft3(n) = t(n); ft4(n) = 2*cos(2*pi*t(n)/10); end; %usamos el comando plot %min() es el minimo del arreglo 1D %max() es el maximo del arreglo 1D figure(1) plot(t,ft1); title('funcion f_{1}(t)'); xlabel('tiempo t(s)'); ylabel('funcion f_{1}(t) (m)'); legend('f_{1}(t)'); axis([min(t), max(t), 1.1*min(ft1), 1.1*max(ft1)]) grid on; box on; figure(2) plot(t,ft2); title('funcion f_{2}(t)'); xlabel('tiempo t(s)'); ylabel('funcion f_{2}(t) (m)'); legend('f_{2}(t)'); axis([min(t), max(t), 1.1*min(ft2), 1.1*max(ft2)]) grid on; box on; figure(3) plot(t,ft3); title('funcion f_{3}(t)'); xlabel('tiempo t(s)'); ylabel('funcion f_{3}(t) (m)'); legend('f_{3}(t)'); axis([min(t), max(t), 1.1*min(ft3), 1.1*max(ft3)]) grid on; box on; figure(4) plot(t,ft4); title('funcion f_{4}(t)'); xlabel('tiempo t(s)'); ylabel('funcion f_{4}(t) (m)'); legend('f_{4}(t)'); axis([min(t), max(t), 1.1*min(ft4), 1.1*max(ft4)]) grid on; box on; %% todos los graficos en un mismo plot para comparar figure(5) plot(t,ft1, t,ft2, t,ft3, t,ft4); title('funciones f(t)'); xlabel('tiempo t(s)'); ylabel('funciones f(t) (m)'); legend('f_{1}(t)', 'f_{2}(t)', 'f_{3}(t)', 'f_{4}(t)'); grid on; box on; %%usando subplot(numero_fila,numero columa,numero grafico) figure(6) subplot(2,2,1) plot(t,ft1); title('funcion f_{1}(t)'); xlabel('tiempo t(s)'); ylabel('funcion f_{1}(t) (m)'); legend('f_{1}(t)'); axis([min(t), max(t), 1.1*min(ft1), 1.1*max(ft1)]) grid on; box on; subplot(2,2,2) plot(t,ft2); title('funcion f_{2}(t)'); xlabel('tiempo t(s)'); ylabel('funcion f_{2}(t) (m)'); legend('f_{2}(t)'); axis([min(t), max(t), 1.1*min(ft2), 1.1*max(ft2)]) grid on; box on; subplot(2,2,3) plot(t,ft3); title('funcion f_{3}(t)'); xlabel('tiempo t(s)'); ylabel('funcion f_{3}(t) (m)'); legend('f_{3}(t)'); axis([min(t), max(t), 1.1*min(ft3), 1.1*max(ft3)]) grid on; box on; subplot(2,2,4) plot(t,ft4); title('funcion f_{4}(t)'); xlabel('tiempo t(s)'); ylabel('funcion f_{4}(t) (m)'); legend('f_{4}(t)'); axis([min(t), max(t), 1.1*min(ft4), 1.1*max(ft4)]) grid on; box on; %% otros graficos figure(7) subplot(2,2,1); bar(t,ft1); title('funcion f_{1}(t)'); xlabel('tiempo t(s)'); ylabel('funcion f_{1}(t) (m)'); legend('f_{1}(t)'); axis([min(t), max(t), 1.1*min(ft1), 1.1*max(ft1)]) grid on; box on; subplot(2,2,2); area(t,ft1); title('funcion f_{1}(t)'); xlabel('tiempo t(s)'); ylabel('funcion f_{1}(t) (m)'); legend('f_{1}(t)'); axis([min(t), max(t), 1.1*min(ft1), 1.1*max(ft1)]) grid on; box on; subplot(2,2,3); stem(t,ft1); title('funcion f_{1}(t)'); xlabel('tiempo t(s)'); ylabel('funcion f_{1}(t) (m)'); legend('f_{1}(t)'); axis([min(t), max(t), 1.1*min(ft1), 1.1*max(ft1)]) grid on; box on; subplot(2,2,4); plot(t,ft1,'*'); title('funcion f_{1}(t)'); xlabel('tiempo t(s)'); ylabel('funcion f_{1}(t) (m)'); legend('f_{1}(t)'); axis([min(t), max(t), 1.1*min(ft1), 1.1*max(ft1)]) grid on; box on; %% graficos en escalas lineales y logaritmicas m = 1; k = 400*pi^2; c = 0.1; F = 10; for n = 1:101 f(n) = (n-1); w = 2*pi*f(n) H(n) = F/sqrt( (k - w^2*m)^2 + (w*c)^2 ); end; figure(8) subplot(2,2,1); plot(f,H); title('funcion respuesta de frecuencia'); xlabel('frecuencia f(Hz)'); ylabel('H(f) (m)'); legend('H(f)'); grid on; box on; subplot(2,2,2); semilogx(f,H); title('funcion respuesta de frecuencia'); xlabel('frecuencia f(Hz)'); ylabel('H(f) (m)'); legend('H(f)'); grid on; box on; subplot(2,2,3); semilogy(f,H); title('funcion respuesta de frecuencia'); xlabel('frecuencia f(Hz)'); ylabel('H(f) (m)'); legend('H(f)'); grid on; box on; subplot(2,2,4); loglog(f,H); title('funcion respuesta de frecuencia'); xlabel('frecuencia f(Hz)'); ylabel('H(f) (m)'); legend('H(f)'); grid on; box on;;