Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
# EulerMethod
A repository for the implementation of the Euler method
Program uses.
-main.c
-funciones.c
-funciones.h
-tipo.h
both .h are included in main.c
gcc -o main.exe main.c funciones.c
Grafica.dat is with "2" in ecuation
Graphic.dat is with "0.2" in ecuation
Binary file added TDA_P1_v1.pdf
Binary file not shown.
Binary file added TDA_P1_v2.pdf
Binary file not shown.
Binary file added TDA_P1_v3.pdf
Binary file not shown.
48 changes: 48 additions & 0 deletions d
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
commit e69cad06c35d7b656e5830de62e7f1f4a81b0963 (HEAD -> Students)
Author: CASTRO BOUQUET ILDEFONSO <ildefonsocb13@gmail.com>
Date: Thu Oct 1 11:21:25 2020 -0500

English Traduction, added function for resolving ecuation, executable added, prueba.c isn't part of programm just for tests, graphic.dat is now the output of the program.

commit 30348dc829359c4c53bec2b9eb1a29885f5fea35
Author: CASTRO BOUQUET ILDEFONSO <ildefonsocb13@gmail.com>
Date: Sun Sep 27 20:01:33 2020 -0500

First Commit

commit 8d31a53dbeeb1f428b8d86b31999a4a2108ab0fc (origin/Students, origin/HEAD)
Merge: a313d56 2dff68b
Author: Cesar Angeles <36006369+CesarAng28@users.noreply.github.com>
Date: Sat Sep 26 10:52:56 2020 -0500

Merge pull request #3 from DavidEPA2001/Students

Add files via upload

commit a313d56d9bd20bc569d78bcbcd9746757765350b
Author: Cesar Angeles <cesar.angeles@hotmail.es>
Date: Fri Sep 25 14:50:29 2020 -0500

removed example file

commit 2dff68be77193a4fde9c0ac771360e9d5d3f1a12
Author: DavidEPA2001 <70725973+DavidEPA2001@users.noreply.github.com>
Date: Thu Sep 24 23:38:21 2020 -0500

Add files via upload

PDF introduccion

commit ca580d80f96be5fa25d9b61a37539df9eef66095
Author: Cesar Angeles <cesar.angeles@hotmail.es>
Date: Thu Sep 24 17:37:16 2020 -0500

Added Doc.docx

commit 904bfe742f02b876ebf703de621df0221b469fd9 (origin/master)
Author: Cesar Angeles <36006369+CesarAng28@users.noreply.github.com>
Date: Tue Sep 22 11:07:14 2020 -0500

Create README.md

Added README file
154 changes: 154 additions & 0 deletions funciones.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
//
// funciones.c
//
//
// Created by Castro Bouquet Ildefonso on 27/09/2020.
// Created by Venegas Ramirez Giovanni Josue on 27/09/2020.
//

/* Libraries */
#include<stdio.h>
#include<stdlib.h>

#include"tipo.h"

/* funciones.c -- Functions */

/**
*This function generates a menu for the program, asking if user wants to set values or use the predetermined.
*
*@param
* datos(DATOS *)
*
*/
void menu(DATOS *datos)
{
float x;
do
{
printf("====================================================\n");
printf("= MENU =\n");
printf("=1) Set values for Dt, Weight, K or cuantity =\n");
printf("=2) Calculate Graphic =\n");
printf("= =\n");
printf("====================================================\n");
printf("Input an option: ");
scanf("%f",&x);
if((x!=1)&&(x!=2))
{
printf("Thats not a valid value.\n");
}
if(x==2)
{
return;
}
if(x == 1)
{
do
{
printf("Insert value for Dt (s):");
scanf("%f",&datos->delta);
if(datos->delta<=0)
{
printf("Value out of range (>0-infinity)\n");
}
}while(datos->delta<=0);
do
{
printf("Introduce weight value (kg):");
scanf("%f",&datos->masa);
if(datos->masa<=0)
{
printf("Value out of range (>0-infinity)\n");
}
}while(datos->masa<=0);
do
{
printf("Introduce value for k constant of the bongee(N/m^2):");
scanf("%f",&datos->k);
if(datos->k<=0)
{
printf("Value out of range (>0-infinity)\n");
}
}while(datos->k<=0);
do
{
printf("Introduce how many dots are going to be calculated:");
scanf("%d",&datos->cantDelta);
if(datos->cantDelta<=0)
{
printf("Value out of range (>0-infinity)\n");
}
}while(datos->cantDelta<=0);//es el valor del for, quiero 15 medidas, osea de x hasta x+15deltas
}
}while(x!=2);
}

/**
*This function creates a file and saves the location on a variable.
*
*@param
* file(FILE *)
*@returns
* 0 if cant create a file
* 1 if file had been created corretly
*/
int CreateFile(FILE **file)
{
*file=fopen("graphic.dat","w");
if(*file==NULL)
{
return 0;
}
else
{
return 1;
}
}

/**
*This function takes the array and print the information from it to the file.
*
*@param
* files(FILE *)
* array[][](float *)
*
*/
void FillFile(FILE *file,float array[][2],DATOS *datos)
{
int i;
for(i=0;i<datos->cantDelta;i++)
{
fprintf(file,"%f, %f\n",array[i][0],array[i][1]);
}
}

/**
*This function takes the variables and replace them in the main ecuation, solve it, and save the results in the array.
*
*@param
* datos(DATOS *)
* array[][](float *)
*
*/
void DesarrolloEcuacion(DATOS *datos,float array[][2])
{
float t,n;
int i;
t=0;
for (i=0; i<datos->cantDelta; i++)
{
if(i==0)
{
array[i][1]=10;
array[i][0]= t; //time value
array[i+1][1]=10;
}
if(i>=1)
{
array[i+1][1]=0-(array[i-1][1])*((1)+(((datos->k)*(datos->delta)*(datos->delta))/datos->masa))+(0.2)*(array[i][1])*(datos->delta)+(datos->delta)*(datos->delta)*9.81;/*agregar 0.2*/
}
t=t+datos->delta;
array[i+1][0]= t; //time value
}
}
65 changes: 65 additions & 0 deletions funciones.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
//
// funciones.h
//
//
// Created by Castro Bouquet Ildefonso on 27/09/2020.
// Created by Venegas Ramirez Giovanni Josue on 27/09/2020.
//
#ifndef funciones_h
#define funciones_h

#include <stdio.h>

#ifdef funciones_IMPORT
#define EXTERN
#else
#define EXTERN extern
#endif

/* funciones.h -- Function prototypes */

/**
*This function generates a menu for the program, asking if user wants to set values or use the predetermined.
*
*@param
* datos(DATOS *)
*
*/
EXTERN void menu(DATOS *datos);

/**
*This function creates a file and saves the location on a variable.
*
*@param
* file(FILE *)
*@returns
* 0 if cant create a file
* 1 if file had been created corretly
*/
EXTERN int CreateFile(FILE **file);

/**
*This function takes the array and print the information from it to the file.
*
*@param
* files(FILE *)
* array[][](float *)
*
*/
EXTERN void FillFile(FILE *file,float array[][2],DATOS *datos);

/**
*This function takes the variables and replace them in the main ecuation, solve it, and save the results in the array.
*
*@param
* datos(DATOS *)
* array[][](float *)
*
*/
EXTERN void DesarrolloEcuacion(DATOS *datos,float array[][2]);


#undef funciones_IMPORT
#undef EXTERN

#endif /* funciones_h */
100 changes: 100 additions & 0 deletions grafica.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
0.000000, 10.000000
0.100000, 10.000000
0.200000, -9.785233
0.300000, -10.180938
0.400000, 9.761258
0.500000, 10.559104
0.600000, -9.533319
0.700000, -10.739663
0.800000, 9.496070
0.900000, 11.117182
1.000000, -9.254760
1.100000, -11.296820
1.200000, 9.204046
1.300000, 11.673141
1.400000, -8.949183
1.500000, -11.851300
1.600000, 8.884834
1.700000, 12.225858
1.800000, -8.616258
1.900000, -12.401965
2.000000, 8.538120
2.100000, 12.774178
2.200000, -8.255688
2.300000, -12.947642
2.400000, 8.163632
2.500000, 13.316912
2.600000, -7.867225
2.700000, -13.487130
2.799999, 7.761142
2.899999, 13.852845
2.999999, -7.450662
3.099999, -14.019198
3.199999, 7.330467
3.299999, 14.380734
3.399999, -7.005839
3.499999, -14.542591
3.599999, 6.871469
3.699999, 14.899308
3.799999, -6.532646
3.899998, -15.056022
3.999998, 6.384064
4.099998, 15.407269
4.199998, -6.031019
4.299998, -15.558184
4.399998, 5.868214
4.499998, 15.903299
4.599998, -5.500949
4.699998, -16.047747
4.799998, 5.323936
4.899998, 16.386057
4.999998, -4.942480
5.099998, -16.523357
5.199997, 4.751300
5.299997, 16.854179
5.399997, -4.355711
5.499997, -16.983644
5.599997, 4.150435
5.699997, 17.306284
5.799997, -3.740797
5.899997, -17.427217
5.999997, 3.521525
6.099997, 17.740976
6.199996, -3.097952
6.299996, -17.852676
6.399996, 2.864815
6.499996, 18.156843
6.599996, -2.427451
6.699996, -18.258598
6.799996, 2.180608
6.899996, 18.552465
6.999996, -1.729630
7.099996, -18.643562
7.199996, 1.469272
7.299995, 18.926411
7.399995, -1.004888
7.499995, -19.006128
7.599995, 0.731240
7.699995, 19.277237
7.799995, -0.253689
7.899995, -19.344852
7.999995, -0.032994
8.099995, 19.603500
8.199995, 0.523439
8.299995, -19.658295
8.399996, -0.822867
8.499996, 19.903755
8.599997, 1.325900
8.699997, -19.945002
8.799997, -1.637749
8.899998, 20.176556
8.999998, 2.153028
9.099998, -20.203533
9.199999, -2.476940
9.299999, 20.420456
9.400000, 3.004091
9.500000, -20.432444
9.600000, -3.339673
9.700001, 20.634022
9.800001, 3.878284
9.900002, -20.630306
Loading