summaryrefslogtreecommitdiff
path: root/accelarray.c
diff options
context:
space:
mode:
authorAlexander Pickering <alexandermpickering@gmail.com>2017-02-06 11:26:44 -0500
committerAlexander Pickering <alexandermpickering@gmail.com>2017-02-06 11:26:44 -0500
commit97a693d996c79fb2a008b19750d8bb45512e01a2 (patch)
tree6df17bfe7de7c59f7b1083828d71a91e61fae9fa /accelarray.c
downloadengr0016-master.tar.gz
engr0016-master.tar.bz2
engr0016-master.zip
Inital commitHEADmaster
Diffstat (limited to 'accelarray.c')
-rw-r--r--accelarray.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/accelarray.c b/accelarray.c
new file mode 100644
index 0000000..293b841
--- /dev/null
+++ b/accelarray.c
@@ -0,0 +1,36 @@
+/* File: accelarray.c
+ Calculate the acceleration using arrays fora ccel and time using 11 points */
+
+#include <stdio.h>
+#include <math.h>
+
+#define M_G 9.81
+#define N 11
+
+int main()
+{
+ double a[N],t[N];
+ double mu=0.2;
+ double m = 5.0;
+ double p;
+ int i;
+
+ double t0 = 0.0;
+ double tf = 10.0;
+
+ for(i=0;i<N;i++)
+ {
+ t[i] = t0 + i*(tf-t0)/(N-1);
+ p = 4*sin(t[i]-3)+20;
+ a[i] = (p-mu*m*M_G)/m;
+ }
+
+ printf("time(s) accel (m/s^2)\n");
+ printf("--------------------\n");
+ for(i=0;i<N;i++)
+ {
+ printf("%8.4f%5c%8.4f\n",t[i],'\0',a[i]);
+ }
+ return 0;
+
+}