Posts

Showing posts from September, 2011

create a function file that calculates the trajectory of a projectile. The inputs to the function are the initial velocity and the angle at which the projectile is fired. The outputs from the function are the maximum height and distance. In addition, the function generates a plot of the trajectory. Use the function to calculate the trajectory of a projectile that is fired at a velocity of 230 m/sec at an angle of 39deg.

Image
Problem :                                 create a function file that calculates the trajectory of a projectile. The inputs to the function are the initial velocity and the angle at which the projectile is fired. The outputs from the function are the maximum height and distance. In addition, the function generates a plot of the trajectory. Use the function to calculate the trajectory of a projectile that is fired at a velocity of 230 m/sec at an angle of 39deg.  USING MATLAB SOFTWARE Version 7.0 SOLUTION:- %Write it in script file function[hmax,dmax]=trajectory(V0,theta)               g=9.81; V0x=V0*cos(theta); V0y=V0*sin(theta); thmax=V0y/g; hmax=V0y^2/(2*g); ttotal=2*thmax dmax=V0x*ttotal  % creating a trajectory plot tplot=linspace(0,ttotal,200); x=V0x*tplot; y=V0y*tplot-0.5*g*tplot...

The co-efficient of friction mu can be determined in an experiment by measuring the force F required to move a mass m. when F is measured and m is known the coefficient of friction can be calculated by mu=F/mg (g=9.81 m/sec2) results from measuring F in six tests are given in the table below. Determine the coefficient of friction in each test, and average from all tests.

Problem :                            The co-efficient of friction mu can be determined in an experiment by measuring the force F required to move a mass m. when F is measured and m is known the coefficient of friction can be calculated by mu=F/mg (g=9.81 m/sec 2) results from measuring F in six tests are given in the table below. Determine the coefficient of friction in each test, and average from all tests. Test # 1 2 3 4 5 6 Mass m-kg 2 4 5 10 20 50 Force F -N 12.5 23.5 30 61 117 294 USING MATLAB SOFTWARE SOLUTION: %IN COMMAND WINDOW >> m=[2 3 5 10 20 50]; >>   f=[12.5 23.5 50 61 117 294]; >>   mu=f./(m*9.8) mu =     0.6378     0.7993     1.0204     0.6224 ...

Three forces are applied to a bracket as shown. Determine the total (equivalent) force applied to the barcket

Problem:          % Three forces are applied to a bracket as shown. Determine the total (equivalent) force applied to the barcket% %IN COMMAND WINDOW >> F1m=400;F2m=500;F3m=700; >> Th1=-20*pi/180;Th2=30*pi/180;Th3=143*pi/180; >> F1=F1m*[cos(Th1) sin(Th1)] F1 =   375.8770 -136.8081 >> F2=F2m*[cos(Th2) sin(Th2)] F2 =   433.0127   250.0000 >> F3=F3m*[cos(Th3) sin(Th3)] F3 =  -559.0449   421.2705 >> Ftotal=F1+F2+F3 Ftotal =   249.8449   534.4625 >> Ftotalm=sqrt(Ftotal(1)^2+Ftotal(2)^2) Ftotalm =   589.9768 >> Th=(180/pi)*tan(Ftotal(2)/Ftotal(1)) Th =   -89.7088

To determine Nearest of temp after 3 hours

Problem : To determine Nearest of temp after 3 hours.. >>% To determine Nearest of temp after 3 hours..% >> Ts=38;T0=120;K=0.45;t=3; >> T=round(Ts+(T0-Ts)*exp(-K*t)) T = 59

A trigonometric identity is given by cos2(x/2)=(tanx+sinx)/2.tanx verify that the identity is correct by calculating each side of the equation substituting x=pi/5

  Problem :          A trigonometric identity is given by cos2(x/2)=(tanx+sinx)/2.tanx verify that the identity is correct by calculating each side of the equation substituting x=pi/5 >> %A trigonometric identity is given by cos2(x/2)=(tanx+sinx)/2.tanx verify that the identity is correct by calculating each side of the equation substituting x=pi/5% >> x=pi/5; >> LHS=cos(x/2)^2 LHS = 0.9045 >> RHS=(tan(x)+sin(x))/(2*tan(x)) RHS = 0.9045

c program to multiplication of two 3*3 matrices

     /* c program to multiplication of two 3*3 matrices*/ #include<stdio.h> #include<conio.h> void main() {      int m1[3][3],m2[3][3],prod[3][3];      int i,j,k;      clrscr();       printf("enter the first matrix : \n");         for(i=0;i<3;i++)           for(j=0;j<3;j++)            scanf("%d",&m1[i][j]);      printf("enter 2nd matrix : \n");          for(i=0;i<3;i++)            for(j=0;j<3;j++)             scanf("%d",&m2[i][j]); /* multiplication of matrix */       for(i=0;i<3;i++)      for(j=0;j<3;j++)  ...

c program to subtract two 3*3 matrices

/*c program to subtract two 3*3 matrices*/ #include<stdio.h> #include<conio.h> void main()   {     int m1[3][3],m2[3][3],msub[3][3];     int i,j;     clrscr();     printf("type in 9 integer number of first matrix:\n");     for(i=0;i<3;++i)        for(j=0;j<3;++j)                    scanf("%d",&m1[i][j]);     printf("\n type in 9 integer number of first matrix:\n");     for(i=0;i<3;++i)        for(j=0;j<3;++j)                    scanf("%d",&m2[i][j]); /*matrix subtraction proceeds as follows...*/    for(i=0;i<3;++i)    for(j=0;j<3;++j)        msub[i][j]=m1[i][j]-m2...

c program to add two 3*3 matrices

/*c program to add two 3*3 matrices*/ #include<stdio.h> #include<conio.h> void main()   {     int m1[3][3],m2[3][3],madd[3][3],msub[3][3];     int i,j;     clrscr();     printf("type in 9 integer number of first matrix:\n");     for(i=0;i<3;++i)        for(j=0;j<3;++j)                    scanf("%d",&m1[i][j]);     printf("\n type in 9 integer number of first matrix:\n");     for(i=0;i<3;++i)        for(j=0;j<3;++j)                    scanf("%d",&m2[i][j]); /*matrix addition proceeds as follows...*/     for(i=0;i<3;++i)       for(j=0;j<3;++j)      ...

to arrange number descending using bubble sort technique

/*to arrange number descending using bubble sort technique*/ #include<stdio.h> #include<conio.h> void main() {   int num[10];   int loop,i;   int last=10;   int exchange;   int temp;   clrscr();   printf("enter the 10 number\n");   for(i=0;i<10;++i)    scanf("%d",&num[i]); for(loop=0;loop<9;++loop) {      exchange=0;      for(i=0;i<(last-1);i++)                   if(num[i]>num[i+1])                     {                       temp=num[i];                       num[i]=num[i+1];     ...

to arrange number ascending using bubble sort techniqu

                  /*to arrange number ascending using bubble sort technique*/ #include<stdio.h> #include<conio.h> void main() {   int num[10];   int loop,i;   int last=10;   int exchange;   int temp;  clrscr();  printf("enter the 10 number\n");  for(i=0;i<10;++i)    scanf("%d",&num[i]);  for(loop=0;loop<9;++loop) {     exchange=0;      for(i=0;i<(last-1);i++)                  if(num[i]<num[i+1])                     {                       temp=num[i];                   ...

sum and average of 3 numbers

/*sum and average of 3 numbers*/ #include <stdio.h> #include <conio.h> void main() { int n1,n2,n3; float sum,average; printf("enter 3 integer numbers\n"); sum=(n1+n2+n3); average=sum/3; printf("The sum of 3 numbers is=%f\n,sum); printf=("The average of numbers=%f/n",average); getch() } out put please enter 3 integer numbers 12 25 33 sum of 3 numbers=70.000000 avg of 3 numbers=23.333334

Largest of 3 number

/*Largest of 3 number */ #include<stdio.h> #include<conio.h> void main() { int a,b,c; printf("enter the 3 numbers\n"); scanf("%d %d %d",&a,&b,&c); if(a>b && a>c) printf("a is greater\n"); else if(b>a && b>c) printf("b is greater"); else printf("c is greater"); getch(); } out put enter the 3 numbers 9 7 20 c is greater

To find whether a number is prime or not

#include<stdio.h> #include<conio.h> main() {    int i,number,remainder,interval;    clrscr();  /*program to test the prime property of a given number*/  printf("type in the number to be tested\n");  scanf("%d",&number);  interval=number/2;  for(i=2; i<=interval; ++i)     {     remainder=number%i;     if(remainder==0)     break;     }   if(remainder!=0)     printf("given number %d is a PRIME NUMBER\n",number);   else     printf("given number %d is not a PRIME NUMBER\n",number);   } OUTPUT type in the number to be tested 43 given number 43 is a PRIME NUMBER

finding the roots of the quadratic equation using switch-statement

#include<stdio.h> #include<conio.h> void main() { int option; float a,b,c,d; float root1,root2,r1,r2; clrscr(); printf("enterthe value of a,b,c\n"); scanf("%f%f%f",&a,&b,&c); if (a==0||b==0||c==0) { printf("\n error_we cannot analyse"); exit(); } d=(b*b-4*a*c); if(d>0)  option=1; else  if(d<0)  option=2; else  option=3; switch(option) { case1: printf("roots are real & distinct\n"); root1=(-b+sqrt(d))/2*a; root2=(-b-sqrt(d))/2*a; printf("\n root1=%f root2=%f\n",root1,root2); break; case 2: printf("\n roots are imaginary & complex\n"); r1=-b/2*a; r2=sqrt(abs(d))/2*a; printf("root1=%f+%f\n",r1,r2); case 3: printf("\n roots are real & equal\n"); root1=root2=-b/2*a; printf("root1=%f\n,root2=%f\n",root1,root2); break; } getch(); } OUTPUT enter the value of a,b,c 22,33,44  roots are imaginary & complex...

whether number is even or odd

/*whether number is even or odd*/ #include<stdio.h> #include<conio.h> void main() { int num,remainder; clrscr(); printf("enter the number\n"); scanf("%d",&num); remainder=num%2; if (remainder==0) printf("the number is even\n"); else printf("the number is odd\n"); getch(); } OUTPUT enter the number 121  the number is odd

sum of digit of given number

/*sum of digit of given number*/ #include<stdio.h> #include<conio.h> void main() { int number,sum=0,r; clrscr(); printf("enter the number\n"); scanf("%d",&number); do { r=number%10; sum=sum+r; number=number/10; } while(number!=0); printf("sum of digit is=%d\n",sum); getch(); } OUTPUT enter the number 123 sum of digit is=6