ee140projects[1]

ee140projects[1] - printf("b is %f...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
#include <stdio.h> //preject1 finding the best fit line int main() { float x ; float y ; float b,m; int n; int i; float xy=0, x1=0, y1=0, xx=0; float avgXY, avgX1, avgY1,avgXX; printf("please eneter n \ n");//have to enter the number of points to be plotted scanf("%d",&n); for(i=1; i<=n; i++ ){ printf("please enter x and y (order pair): ");//enter your order pair for n times scanf("%f %f", &x, &y); xy=xy+(x*y); //adding up x*y x1=x1+x;//adding up x y1=y1+y;//adding up y xx=xx+(x*x); //adding up x*x } //the loop ends avgXY=xy/n; //taking the average or the sum of x*y avgX1=x1/n;//taking the average or the sum of x avgY1=y1/n;//taking the average or the sum of y avgXX=xx/n;//taking the average or the sum of x*z m = (avgXY-(avgX1*avgY1))/(avgXX-(avgX1*avgX1));//calculation the slope b = ((avgXX*avgY1)-(avgX1*avgXY))/(avgXX-(avgX1*avgX1));//calculation the slope intercept
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: printf("b is %f \n",b);//printing the value of the slope intercept printf("m is %f \n",m);//printing the value of the slope printf(" the best fit line is \ n y = %fx+%f \n", m,b); //printing the equation of the line return 0; } //happy face Project2 # include<stdio.h> double func(double f, int T){ int i; double inverse[T]; for(i = 0;i<T;i++){ inverse[i] = f[T-1-i]; } for(i = 0;i<T;i++){ printf("the inverse fuction is %lf \n",inverse[i]); } } double conv(double c, int T){ int i,j, t; double f[T],inverse[T]; func(f,T); for(j = 0; j <T;j++){ c[j] += inverse[T-1-j]*f[j]; printf("%lf",c[j]); } } int main(void){ int i,t,T; double b, inverse; printf("please enter T"); scanf("%d", &T); double f[T]; for(i = 0; i < T; i++){ printf("please enter the elements of the arrays", i); scanf("%lf",&f[i]); } conv(b,T); return 0; }...
View Full Document

This note was uploaded on 09/04/2011 for the course EE 140 taught by Professor Lanxiang during the Spring '11 term at Montgomery College.

Page1 / 3

ee140projects[1] - printf("b is %f...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online