Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Agregado ejercicio 6, con maxima y octave. Hecho a y b (con euler) casi

  • Loading branch information...
commit a654f7b422692adf70fae7aab44512e12f9fea55 1 parent 098842d
@escudero89 authored
Showing with 155 additions and 0 deletions.
  1. +79 −0 Six/Cristian/Maxima4.wxm
  2. +76 −0 Six/Cristian/eje6.m
View
79 Six/Cristian/Maxima4.wxm
@@ -0,0 +1,79 @@
+/* [wxMaxima batch file version 1] [ DO NOT EDIT BY HAND! ]*/
+/* [ Created with wxMaxima version 11.08.0 ] */
+
+/* [wxMaxima: comment start ]
+Modelo de impedancias a partir de aplicar Laplace a la Ecuación Diferencial
+ [wxMaxima: comment end ] */
+
+/* [wxMaxima: input start ] */
+z345 : z3 + z4 + z5;
+z2345 : z2 * z345 / (z2 + z345);
+z12345 : z1 + z2345;
+/* [wxMaxima: input end ] */
+
+/* [wxMaxima: input start ] */
+I : Ei / z12345;
+V : I * z2345;
+i : V / z345;
+/* [wxMaxima: input end ] */
+
+/* [wxMaxima: input start ] */
+Eo : z5 * i;
+ratsimp(Eo : z5 * I);
+/* [wxMaxima: input end ] */
+
+/* [wxMaxima: comment start ]
+Reemplazo impedancias por valores en S:
+ [wxMaxima: comment end ] */
+
+/* [wxMaxima: input start ] */
+z1 : R1;
+z2 : (s*C2)^-1;
+z3 : R3;
+z4 : (s*C4)^-1;
+z5 : R5;
+/* [wxMaxima: input end ] */
+
+/* [wxMaxima: comment start ]
+Reemplazo para obtener una transformación de Euler (guardo los anteriores valores de z):
+ [wxMaxima: comment end ] */
+
+/* [wxMaxima: input start ] */
+z1_o : z1;
+z2_o : z2;
+z3_o : z3;
+z4_o : z4;
+z5_o : z5;
+/* [wxMaxima: input end ] */
+
+/* [wxMaxima: input start ] */
+s : (1 - z^-1) / T;
+H_z : ratsimp(Eo / Ei);
+/* [wxMaxima: input end ] */
+
+/* [wxMaxima: comment start ]
+Voy a hacer ecuaciones en diferencias:
+ [wxMaxima: comment end ] */
+
+/* [wxMaxima: input start ] */
+Ztrans : expand(H_z * X_z / Y_z)$
+/* [wxMaxima: input end ] */
+
+
+/* [wxMaxima: input start ] */
+ratsubst(X[n], X_z * z^2, Ztrans)$
+ratsubst(X[n-1], X_z * z, %)$
+ratsubst(X[n-2], X_z, %)$
+
+ratsubst(Y[n], Y_z * z^2, %)$
+ratsubst(Y[n-1], Y_z * z, %)$
+EcuDif : ratsubst(Y[n-2], Y_z, %)$
+
+up : expand(num(EcuDif));
+down : expand(num(EcuDif^-1));
+
+solve(up = down, Y[n]);
+/* [wxMaxima: input end ] */
+
+/* Maxima can't load/batch files which end with a comment! */
+"Created with wxMaxima"$
View
76 Six/Cristian/eje6.m
@@ -0,0 +1,76 @@
+#! /usr/bin/octave -qf
+1;
+
+clear all;
+
+# Transformacion de Euler
+function [ret] = trans_euler(X, T, Y = [0 0 0])
+
+ R1 = 1100;
+ C2 = 1e-6;
+ R3 = 2200;
+ C4 = 2e-6;
+ R5 = 1000;
+
+
+ N = length(X);
+
+ for n = 3 : N
+
+ # Mega alta ecuacion sacada de Maxima4.wmx
+
+ Y(n) = ((((X(n) + Y(n - 1) - X(n - 1)) * C4 + (X(n) \
+ - X(n - 1)) * C2) * R5 + Y(n - 1) * C4 * R3 \
+ + (Y(n - 1) * C4 + Y(n - 1) * C2) * R1) * T \
+ + (X(n) - 2 * X(n - 1) + X(n - 2)) * C2 * C4 * R5^2 \
+ + ((X(n) - 2 * X(n - 1) + X(n - 2)) * C2 * C4 * R3 \
+ + (2 * Y(n - 1) - Y(n - 2)) * C2 * C4 * R1) * R5 \
+ + (2 * Y(n - 1) - Y(n - 2)) * C2 * C4 * R1 * R3) \
+ / (T^2 + (C4 * R5 + C4 * R3 + (C4 + C2) * R1) * T \
+ + C2 * C4 * R1 * R5 + C2 * C4 * R1 * R3);
+
+ endfor
+
+ ret = Y;
+
+endfunction
+
+# Valores iniciales
+
+ini = -0.1;
+fin = 1;
+
+fm = 100;
+Tm = 1/fm;
+
+t = ini : Tm : fin - Tm;
+N = length(t);
+
+dirac = (abs(t) < 1e-13);
+
+# Probamos con un impulso y obtenemos la respuesta del sistema
+
+H = trans_euler(dirac, Tm);
+
+# Hasta el indice 11 son ceros, por lo que no lo uso para convolucionar
+
+H_c = H(11 : length(H));
+
+# Ingresamos una fuente alterna de 10Hz y 1V aprox por 0.5 segundos
+
+V = 1;
+f = 10;
+
+Ei = (t >= 0 & t <= 0.5) .* ( V * sin(2 * pi * f * t));
+
+convolucion = conv(Ei, H_c);
+
+clf;
+hold on;
+
+stem(t, Ei, 'b');
+stem(t, trans_euler(Ei, Tm), 'g');
+stem(t, H, 'k');
+plot(t, convolucion(1:N), 'r');
+
+hold off;
Please sign in to comment.
Something went wrong with that request. Please try again.