Private Sub RespIndcal_click() 'cmdCreateTable_Click()
Dim T As Single, T1 As Single 'Tempo en abscsas
Dim T0 As Single, Dt As Single, tf As Single
Dim w As Single, p As Single, sigma As Single
Dim RespImpulso1Orden As Double
Dim R1 As Single, R2 As Single, C As Single
'Titulos en Celdas
Range("B2").Select
ActiveCell.FormulaR1C1 = "Tempo"
Range("B2").Select
[Link] = True
Range("C2").Select
ActiveCell.FormulaR1C1 = "Respuesta al impulso sistema de 1er Orden"
Range("C2").Select
[Link] = True
Range("A2").Select
ActiveCell.FormulaR1C1 = "Tinicial"
Private Sub RespIndical_click() 'cmdCreateTable_Click()
Dim T As Single, T1 As Single 'Tempo en abscsas
Dim t0 As Single, Dt As Single, tf As Single
Dim w As Single, p As Single, sigma As Single
Dim RespImpulso1Orden As Double
Dim R1 As Single, R2 As Single, C As Single
'Titulos en Celdas
Range("B2").Select
ActiveCell.FormulaR1C1 = "Tempo"
Range("B2").Select
[Link] = True
Range("C2").Select
ActiveCell.FormulaR1C1 = "Respuesta al impulso sistema de 1er Orden"
Range("C2").Select
[Link] = True
Range("A2").Select
ActiveCell.FormulaR1C1 = "Tinicial"
Range("A2").Select
[Link] = True
Range("A4").Select
ActiveCell.FormulaR1C1 = "Tfinal"
Range("A4").Select
[Link] = True
Range("A6").Select
ActiveCell.FormulaR1C1 = "Incremento de Tiempo"
Range("A6").Select
[Link] = True
Range("A8").Select
ActiveCell.FormulaR1C1 = "Nro de Puntos"
Range("A8").Select
[Link] = True
Range("A10").Select
ActiveCell.FormulaR1C1 = "Constante de tiempo"
Range("A10").Select
[Link] = True
Range("A12").Select
ActiveCell.FormulaR1C1 = "Valor de p - nro De Periodos"
Range("A12").Select
[Link] = True
Range("A14").Select
ActiveCell.FormulaR1C1 = "R1"
Range("A14").Select
[Link] = True
Range("A16").Select
ActiveCell.FormulaR1C1 = "R2"
Range("A16").Select
[Link] = True
Range("A18").Select
ActiveCell.FormulaR1C1 = "C"
Range("A18").Select
[Link] = True
'Pedir datos
t0 = InputBox("Valor inicial de t (t0):"): Cells(3, 1) = t0 'Tiempo inicial
tf = InputBox("Valor final de t (tf):"): Cells(5, 1) = tf 'Tiempo final
Dt = InputBox("Incremento de t (Dt):"): Cells(7, 1) = Dt 'Incremento
n = Int((tf - t0) / (Dt)) + 1: Cells(9, 1) = n 'Numero de puntos
R1 = InputBox("R1:"): Cells(15, 1) = R1 'Recistencia R1
R2 = InputBox("R2:"): Cells(17, 1) = R2 'Recistencia R2
C = InputBox("C:"): Cells(19, 1) = C 'Capacitor C
T1 = C * R1: Cells(11, 1) = T1 'Tau
'Borra las celdas de rrespuestas anteriores
contador = 0
While Abs(Cells(contador + 3, 2)) Or Abs(Cells(contador + 3, 3)) > 0
Cells(contador + 3, 2) = "": Cells(contador + 3, 3) = ""
contador = contador + 1
Wend
'Tabla de valores de tiempo-Respuesta Indicial
For w = t0 To tf Step Dt
p = (w - t0) / Dt: Cells(13, 1) = p
Cells(p + 3, 3) = RespImpulso1Orden
Next w
Call grafico
End Sub
'Grafico
Sub grafico()
Dim n As Integer, p As Single, ChartsTemp As Object, graf As Object
Dim datos As String
n = Cells(9, 1): p = Cells(13, 1)
'Eliminar datos grafico anterior
Set ChartsTemp = [Link]
If [Link] > 0 Then
ChartsTemp([Link]).Delete
End If
datos = Range(Cells(3, 2), Cells(p + 3, 3)).Address 'rango a greficar
Set graf = [Link] 'grafico y sus caracteristicas
'Caracteristicas
With graf
.Name = "Grafico"
.ChartType = x1XYScatterSmoothNoMarkers
.SetSourceData Source:=Sheets("hoja1").Range(dtos), PlotBy:=x1Columna
.Location Where:=x1LocationAsObject, Name:="Hoja1"
End With
With ActiveChart
.HasTitle = True
.[Link] = "RESPUESTA AL IMPULSO SISTEMA DE 1er ORDEN"
.Axes(x1Category, x1Primary).HasTitle = True
.Axes(x1Category, x1Primary).[Link] = "tiempo"
.Axes(x1Value, x1Primary).HasTitle = True
.Axes(x1Value, x1Primary).[Link] = "Respuesta Indical"
.Axes(x1Value, x1Primary).HasTitle = True
End With
With [Link]
.Left = 200:
.Top = 20:
End With
'El programa termina en una celda vacia
'Range("A15".select
'ActiveCell.FormulaR1C1=""
'Range("A15").Select
'[Link]:Bold=True
'[Link]=false
'[Link] Type:x1dataLabelsShowValue,LegendKey:=False
End Sub