summaryrefslogtreecommitdiff
path: root/linear_spaced.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 /linear_spaced.c
downloadengr0016-master.tar.gz
engr0016-master.tar.bz2
engr0016-master.zip
Inital commitHEADmaster
Diffstat (limited to 'linear_spaced.c')
-rw-r--r--linear_spaced.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/linear_spaced.c b/linear_spaced.c
new file mode 100644
index 0000000..d8dd301
--- /dev/null
+++ b/linear_spaced.c
@@ -0,0 +1,33 @@
+/* File: linear_spaced.c
+ Generates linearly spaced atat for an array with N elements from x0 to xf*/
+
+#include <stdio.h>
+
+#define N 11
+
+int main()
+{
+ double x[N],
+ x0 = 0.0,
+ xf = 5.0;
+ double j = x0;
+
+ int i;
+
+ printf("%-4c",'c');
+ /* generate linearly spaced data for an array with N elements */
+ double step = (xf - x0)/((double)N);
+ for(i=0;i<N;i++)
+ {
+ printf(" %4d ",i);
+ x[i] = j;
+ j += step;
+ }
+ printf("\n%-4c",'c');
+ for(i=0;i<N;i++)
+ {
+ printf(" %4.2f ",x[i]);
+ }
+ printf("\n");
+ return 0;
+}