DAILY ASSIGNMENT D1
You have been assigned responsibility for instructing a new employee at a motor pool whose job it will be to determine what is wrong with vehicles that will not start. When the problem is determined, the vehicle will be assigned to a mechanic for repair. Each morning, the employee is to determine whether any vehicles have been reported as not starting. If any have been reported, the employee is to diagnose each one in turn until all have been assigned to mechanics. Write, in the space below (and/or on the back of this sheet if more space is needed), a complete set of instructions for performing this job. Assume that the problem is one of the following:
a) no fuel is getting to the cylinders,
b) there is an ignition problem (no spark), or
c) the engine will not crank.
If it is a fuel problem, the tank could be empty, or there could be a fuel pump or carburetor/fuel injector problem. If the engine will not crank, it could be a dead battery, bad cable connections, or a bad starter. If the engine cranks and there is fuel entering the cylinders, the problem is in the ignition system.
Your set of instructions should provide for an efficient diagnosis of the problem (in what order should you check the possibilities described above?). Your algorithm does not have to describe HOW to make the required tests, but must state in what order to make them and what to do next based on the results of each check. Assume that your task is complete when the source of the problem has been identified. Keep your wording BRIEF, but complete, for each step. Document your assumptions.
DAILY ASSIGNMENT D2
For this assignment you are to draw a complete flowchart of the logic of for the algorithm given below. Use the space on the back of this sheet or an extra sheet if needed.
Problem: There are a number of apples in a large box which must be sorted into baskets. An apple is either a "large red" one, a "small red" one, or a "green" one.
1. There are 3 empty baskets present and labeled:
#1 – large red
#2 – small red
#3 – green
2. There are counters of some sort present.
3. The person sorting is not color blind and can tell the difference between large and small.
4. Only these three kinds of apples are in the box.
1. Set all counters to zero
2. Are there any apples in large box? (Hint: think "while")
a). If no, skip to Step 6
b). If yes, continue on with next step
3. Select an apple from the box
4. If apple is "green", then
a). Put apple in Basket #3
b). Add 1 to "green" counter
Else, if apple is "small red", then
a). Put apple in Basket #2
b). Add 1 to "small red" counter
a). Put apple in Basket #1
b). Add 1 to "large red" counter
5. Go back to Step 2
6. Display number of "green", "small red", and "large red" apples
DAILY ASSIGNMENT D3
A. Login to a UNIX Workstation from a PC using Exceed X-windows software or a simple telnet program. Perform the following tasks and print the UNIX commands for each exactly as you typed it (correct case, blank spaces where needed, etc.). Use <cr> to indicate a carriage return.
1. Create a second UNIX window (only if you are using Exceed).
2. Display your directory files in a UNIX window.
3. Copy file welcome.dat from the common area ( ~/eg167hcl ) to your directory.
4. Change the name of welcome.dat to welcome.txt.
5. Display the contents of welcome.txt in a UNIX window.
6. Print the contents of welcome.txt on one of the lab's printers. Submit the printout with this sheet.
7. Erase welcome.txt from your directory.
B. Invoke the vi editor (vedit) in a UNIX window by typing vedit d3.cpp and then type in the program shown on the following sheet exactly as shown (replace "Brutus Buckeye" with your name). Save the file, then compile and link it by typing:
> CC -o d3.out d3.cpp
If an error occurs, return to the vi window, correct the program, and re-save the file. If it compiles without an error message, run it by typing d3.out in the UNIX window where you compiled it. When the program is running correctly, and producing correct results, print a copy of d3.cpp by typing print d3.cpp in the UNIX window and submit it with this sheet.
DAILY ASSIGNMENT D3
/* My name is Brutus Buckeye
This is program # D3 for EG H167
Winter Quarter 2001 */
void main ( )
float pi = 3.141593, rad, volume ;
printf ("\n\n\nThis program asks you to enter the radius of\n") ;
printf ("a sphere and then calculates and prints the\n") ;
printf ("volume of the sphere\n") ;
printf ("\nPlease enter the radius of the sphere now > ") ;
scanf ("%f", &rad) ;
printf ("rad= %f pi= %f\n ", rad, pi) ;
volume = 4.0 / 3.0 * pi * rad * rad * rad ;
printf ("\nThe volume of the sphere is %6.1f\n\n\n", volume) ;
DAILY ASSIGNMENT D4
Following is a C program. Evaluate by hand (or with calculator) the C expressions in the order listed below, and write the value assigned to each variable when the program is run and the statements are executed.
void main ( )
int a, b, c, d;
float w, x, y = 4, z;
int e = 3, f = 0.5, g = 2, h = 10.97;
float q = 5, r = .25, s = 7, t = 3/2;
w = g / e - 100 * f; /* w = */
w += h; /* w = */
a = t + pow (g, q); /* a = */
b = --w + t; /* b = */
x = h % e++; /* x = */
y = (e + w) * y; /* y = */
c = (++s); /* c = */
z = r * s + h / e + q; /* z = */
DAILY ASSIGNMENT D5
A. Write a complete C program to 1) prompt the user to input a length in feet from the
keyboard, 2) read the user's response, 3) compute the corresponding length in millimeters (1 inch = 25.4 millimeters), and 4) print the results in the UNIX command window in the form:
There are xxx millimeters in yyy feet
where xxx is the value read in and yyy is the computed value.
The following C statements may be used to input the length in feet:
printf ("\n\nEnter length in feet\n");
scanf ("%f", &ft);
and the following C statement may be used to print the computed length in millimeters:
printf ("There are %f millimeters in %f feet\n\n", mm, ft);
where mm and ft are real (i.e., float) variables.
Save your program as d5.cpp. Test your program by compiling, linking, and running it. When it is working correctly, print the source code file d5.cpp on the printer and submit it with this sheet.
B. Modify your program to also calculate and display the volume (in cubic millimeters) of a sphere whose diameter is the distance (in feet) that was entered from the keyboard. Save your modified program as d5mod.cpp. When it is working correctly print the file d5mod.cpp and include it along with d5.cpp and this sheet.
DAILY ASSIGNMENT D6
Write a complete C/C++ program to open an existing data file d6.dat (copy it from the common area, ~/eg167hcl, to your directory), read each line, and print it on the screen. When your program is working correctly, modify it so that the program will also create and open an output file d6result.txt and print each line from the input file to this output file as well as to the screen. Verify that the output file contents matches the input data contents.
Print a copy of your source code file, d6.c, and a copy of your d6result.txt file and submit them with this sheet.
DAILY ASSIGNMENT D7
It can be shown that by using the principal of interval halving, a person can correctly guess a number between 0 and 10 inclusive in not more than four tries with the correct answer being known for certain after a maximum of three wrong guesses. Write a complete C/C++ program to test whether a user can apply the principle correctly and, every time the program is run, can guess the correct answer in not more than four tries. The algorithm below is one suggestion for the organization of your program. Use one or more if - else if - else structures to implement the decision making/selection process.
1) Inform the user of the rules of the game, namely that he/she has four chances to guess a number in the range 0<= x <= 10 that the computer has selected.
2) Select a random integer number in the range 0<= x <= 10
3) Prompt the user to guess what number was selected.
4) If the user guesses the correct number, print a congratulation message and terminate, otherwise
5) If the user guesses too big a number, print a message stating so and go to step 7, otherwise
6) If the user guesses to small a number, print a message saying so.
7) If the user has made four incorrect guesses, print a condolence message and terminate, otherwise continue with step 3.
DAILY ASSIGNMENT D8
A major use of the switch selection structure in C/C++ is to implement menu-like transfers. For this assignment write a complete C/C++ program to calculate and display the area of 1) a square given the length of one side, 2) a circle given the radius, and 3) an equilateral triangle given the length of one side.
Your program should 1) prompt the user to select which figure is to be used by typing in the name of the figure, 2) prompt the user to enter the required dimension for the figure selected, and 3) calculate and display the area of the selected figure. Your program should accept either upper case or lower case letters for the figure name and either triangle or equilateral triangle for the selection of the triangle. You may use just the first letter of each of the figure names to control the choice of figure.
When the program is running correctly, submit a copy of the source code with this sheet.
DAILY ASSIGNMENT D9
A. Modify your program from assignment D7 so that it offers the user the option to play the game again as many times as desired until he/she elects to quit. The game should execute the first time without asking and then ask whether the user wishes to play again. The user could enter his/her choice by typing a number or a letter. REQUIRE A VALID ANSWER! If the user elects to continue, do not re-seed the random number function. Save your modified program as d9a.cpp. Compile, link run, and if necessary, debug it. When it is running correctly, print the source code file d9a.cpp and submit it with this sheet.
B. Modify your program from assignment D8 so that it offers the user the option to calculate and display the area of one of the three figures as many times as desired until he/she elects to quit. The program should keep offering the user the option to continue with another of the figures until he/she types in "q" or "Q" to quit. When it is running correctly, print the source code file d9b.cpp and submit it with this sheet and d9a.cpp.
DAILY ASSIGNMENT D10
An existing data file d10.dat in the common area contains measured diameters of 20 wristpins. Write a complete C/C++ program to read all of the data, compute the average and standard deviation, display the results, properly identified, in the UNIX Window, and also write them to an output data file d10result.txt. The formula for computing standard deviation is given below:
Save your program in file d10.cpp. Compile, link, and run and, if necessary, debug it, naming your executable file d10.out. When it is running without error and producing correct results, print the source code file d10.cpp, and the output file d10result.txt, and submit them both with this sheet.
DAILY ASSIGNMENT D11
Many times obtaining a rigorous mathematical solution to a problem can be very difficult but an approximate result of sufficient accuracy may be obtained by replacing the complicated expression with a series expansion called the Taylor Series. Retaining just enough terms to give the desired accuracy reduces the computation time. The cosine of an angle may be computed by the Series Expansion:
where the angle x is expressed in radians.
Write a complete C/C++ program to compute the cosines of angles from 0 to 90 degrees in 5-degree increments and print out the results. Your program is to include a function factorial ( ) whose prototype is long factorial (int a); to compute and return the factorial of any integer between 0 <= a <= 10. The computed values are then to be used in main to complete the calculations for the cosines of the angles. Save your program as d11.cpp. Compile, link, test, and debug it. When your program is running and produces the correct results, write the output to a data file d11.txt. Print your program and the data file and submit them with this sheet.
DAILY ASSIGNMENT D12
File d10.dat that you copied from the common area for assignment D10 contains measured diameters of 20 wristpins. Today's assignment is to write a program consisting of a function main ( ) and a function swap ( ) that will input the data from that same file, sort them into ascending order, and display the sorted data in a UNIX window.
Your function main ( ) is to open the file, read all of the values into an array, and then sort them into ascending order by:
1. Comparing successive pairs of the wristpin diameters (for example, compare diameter[k] with diameter[k+1] and, if diameter[k+1] is smaller than diameter[k] ), calling swap ( ) to swap or interchange them as necessary. This is to be done for the index, k, going from 0 to "n-1", where "n" is the index of the last wristpin.
2. If any swaps were made in step 1, repeat step 1, otherwise the sort is complete and you are ready to display the results.
3. When the sort is complete, display the results in a UNIX window.
The function prototype for function swap ( ) is:
void swap (float *, float *) ; /* If you used "float" for the array in D10 */
void swap (double *, double *) ; /* If you used "double" for the array in D10 */
Recall that two variables a and b can be swapped or interchanged by:
1. Declaring a third variable temp.
2. Assigning the value of a to temp.
3. Assigning the value of b to a.
4. Assigning the value of temp to b.
Compile, link, test, and if necessary, debug your program. Name your source code file d12.cpp.
When your program is working correctly, print d12.cpp, execute your program one more time while redirecting your program's output to a file such as d12.txt, print d12.txt, and submit both printed outputs with this sheet.
DAILY ASSIGNMENT D13
A data file named d13.dat exists in the class "common area" on the UNIX system. (The file is thus named "/n5/engraph/eg167hcl/d13.dat" or something similar.) The file contains actual data from one test of an instrumented bicycle from an engineering hands-on lab experiment. You should look at the file on the screen (with a "more" command), but DO NOT print it out, as it contains several thousand (but less than 12,000) lines of data. You will note that at the beginning of the file there are several lines of "header" information followed by many lines of data in four columns. Count by hand the number of lines from the beginning of the file until you get to a line that has the actual data in the four columns. (You will need this number in Step 2 below.) The fourth column is the raw strain data (voltage) values from the lab experiment. Note also that the "header" information includes the sampling rate.
Write a complete C/C++ program, d13.cpp, which does the following:
1. Opens the data file for input.
2. Input the correct number of header lines one by one, display each one on the screen and print each one to a result file (say, d13result.dat), and then discard the information.
3. Input each of the lines of data arranged in the four columns, discarding the data values from each of the first three columns and storing only the data from the fourth column in a one-dimensional array. For skipping over the columns with unwanted data, you will need to use the assignment suppression operator, *, in the scanf format. Your program will need to detect the end-of-file (EOF) to know when to stop inputting data. Close the input file when you reach the EOF.
4. Find the largest value in the array and the smallest value in the array. Also determine the elapsed time in seconds between the largest and smallest values.
5. Display the results on the screen, and also write the results to the output file, d13result.dat. The results to be displayed and printed are:
· The total number of data points in the file
· The maximum voltage and time at which it occurred
· The minimum voltage and time at which it occurred
· The elapsed time between the maximum and minimum values
6. Calculate the strain, e, for the maximum and minimum voltage values, using the appropriate expressions from the hands-on Lab Experience. Display these values on the screen with proper engineering units, and print them to the result file as well.
Compile & link and test your program. Debug it as may be needed. When it is running correctly, print your source code, d13.cpp, and the output file your program generated, d13result.dat, and submit them both with this assignment sheet.
DAILY ASSIGNMENT D14
File d14.dat in the common area contains several names, one per line. Copy the file to your directory and look at it. Write a complete C/C++ program to:
1) open the file,
2) read in the names to an array of strings (an array of arrays of type char),
3) print out the list of names in the original order,
4) using a pointer array sort the names into alphabetical order, and
5) print out the list of names in alphabetical order.
Save your program in a file named d14.cpp. Compile, link, test, and debug it. When it is running without error and producing correct results, print your source code file d14.cpp. Also, run your working program one more time while using UNIX redirection to cause the output from the screen to go into a file, such as d14.txt. Print this text file and include both it and the source code printout with this sheet.
DAILY ASSIGNMENT D15
(Part A.) Using MATLAB, create a set of numbers going from 0 to 10 in increments of 0.1 and store it in a vector named A. Using the equation B = 4*A –2.5, define B. Plot B versus A (B on the vertical axis, A on the horizontal axis). Label the axes with their variable names (A and B) and title the plot "Assignment D15, your name, seat no. xx". Print out the plot and include it with this sheet.
Write the commands you used in the space below.
(Part B.) Using MATLAB, load the data file d15.dat and display it on the screen. Plot the first column versus the second column (second column on the vertical axis). Print out the plot and include it with this sheet.
Write the commands you used in the space below.
DAILY ASSIGNMENT D16
During this quarter you have been using library functions that have had their function prototypes declared in header files such as stdio.h, math.h and stdlib.h. It is often convenient to create and use your own library functions and declarations.
Today's assignment has three parts:
A. Create your own header file mylib.h that contains definitions for the constants:
PI (the value of pi to at least 7 places)
E (the value of e, the base of natural logarithms)
and the function prototypes for the function factorial ( ) that you wrote for assignment D11 and for the following two functions:
double square (double x)
return (x*x) ;
double cube (double x)
B. Create and compile (only) a file mylib.cpp that contains the two functions shown above and also the function factorial ( ) that you wrote for assignment D11. Your compiled file will be named mylib.o.
The compile only command is:
> CC -c mylib.cpp
C. Test your library by writing and testing a short program d16.cpp that contains the pre-processor directive #include "mylib.h" and does the following:
1. Prompts the user to select whether to calculate the area of a circle a = PI*square(r), or the volume of a sphere a = 4./3.*PI*cube(r).
2. Gets the user's response, and then prompts for and gets the radius of the selected shape.
3. Performs the required calculation using your library definitions and functions, and displays the result in a UNIX window.
The compile/link command will be:
> CC -o d16.out d16.cpp mylib.o
When your library and test program are working correctly, print mylib.h, mylib.cpp and d16.cpp and submit them with this sheet.
DAILY ASSIGNMENT D17
The program listed below contains a typedef for struct student, a main program that creates a struct variable st1 of type student and a function fillstruct( ) that obtains data from the user and initializes the struct variable. main ( ) invokes fillstruct ( ) to initialize st1 and then accesses st1 and displays its contents using printf ( ).
Using vedit or other editor, create a file d17.cpp and type in the program. Save the file, compile, link, test, and if necessary, debug it. When it is working correctly, modify it as follows:
1.) Add a member of type char to struct student to hold a string of length 4, for example, a variable named college to hold the abbreviation for a student's college (ENG, ASC, etc.).
2.) Add the necessary statements to fillstruct ( ) to input a value into this new member.
3.) Add a second variable st2 of type student to main ( ).
4.) Add a function call to main ( ) to initialize st2.
5.) Add printf() statements to main ( ) to display the contents of st2.
Compile, link, test, and if necessary, debug your modified program. When it is working correctly, print the source code file d17.cpp and submit it with this sheet.
typedef struct student_record
long int id;
void fillstruct (student *num);
void main ( )
printf ("Student %s, id# %9ld,", st1.name, st1.id);
printf (" has a GPA of %4.2f\n", st1.gpa);
void fillstruct (student *num)
printf ("enter student name ");
printf ("enter id# (no spaces or dashes) ");
scanf ("%ld", &(*num).id);
printf ("enter grade point average ");
scanf ("%f", &(*num).gpa);
DAILY ASSIGNMENT D18
The program listed below contains a typedef for struct student, a main program that creates an array eg167 of type student and a function fillaray ( ) that obtains data from the user and initializes elements of the array. main ( ) invokes fillaray ( ) repeatedly to initialize the array and then displays its contents using by repeated calls to printf ( ).
Using vedit, create a file d18.cpp and type in the program. Save the file, compile, link, test, and if necessary, debug it. when it is working correctly, modify it as follows:
1.) Declare a new struct personal containing members gpa and a string coll of type char.
2.) Replace member gpa of struct student with struct personal.
3.) Modify fillaray ( ) as necessary to correctly initialize struct student.
4.) Change the name of array eg167[ ] to eg167h[ ].
5.) Add the printf ( ) statements in main ( ) to display the contents of array eg167h[ ].
Compile, link, test, and if necessary, debug your modified program. When it is working correctly, print the source code file d18.cpp and submit it with this sheet.
typedef struct student_record
long int id;
void fillaray (student eg167[ ], int k);
void main ( )
void fillaray (student eg167[ ], int k)
printf ("student name ");
printf ("id# (no spaces or dashes) ");
scanf ("%ld", &eg167[k].id);
printf ("grade point average ");
scanf ("%f", &eg167[k].gpa);
int k, n;
for (n = 1; n <= 5; n++)
printf ("Enter data for student # %d\n", n);
fillaray (eg167, n-1);
for (k = 0; k < 5; k++)
printf ("Student %s, id# %9ld,", eg167[k].name, eg167[k].id);
printf (" has a GPA of %4.2f\n", eg167[k].gpa);
DAILY ASSIGNMENT D19
Given the C structure:
you are to write a C++ class definition of Complex. This class should:
1). make the variables real and imag private, and
2). contain the function prototypes for:
a). a member function input that will input two numbers and assign them to real and imag data members,
b). a member function show which will output real, and imag, and
c). a constructor member function which will initialize the data members of an object in this class to appropriate values.
Note that the member functions should be public.
You are to write a complete C++ program which implements the class as described above, including the class functions. You are to provide a small main ( ) program which declares an object in this class and tests its functions. Your main program might look something like:
void main ( )
Complex imag_num1, imag_num2 ;
imag_num1.input ( ) ;
imag_num1.show ( ) ;
imag_num2.show ( ) ;
DAILY ASSIGNMENT D20
The program listed below contains a complete program that includes a header file, defines a class and its two member functions, and has a main program that declares an object that is a member of the class and then invokes (calls) the two member functions to initialize the object and then display its contents.
Using vedit or other editor, create a file d20.cpp and type in the program. Replace the header file with iostream.h Replace each scanf ( ) with a cin. Replace each printf ( ) with a cout. Replace the gets ( ) with a cin.getline ( ). Save the file.
Compile, link, test, and if necessary, debug your modified program. When it is working correctly, print the source code file d20.cpp and submit it with this sheet.
long int id;
void fillaray ( );
void showdata ( );
void main ( )
printf ("Enter the following data for a student\n");
eg.fillaray ( );
eg.showdata ( );
void Student::fillaray ( )
printf ("name ");
printf ("id# (no dashes or spaces) ");
scanf ("%ld", &id);
printf ("grade point average ");
scanf ("%f", &gpa);
void Student::showdata ( )
printf ("Student %s, id# %9ld,", name, id);
printf (" has a GPA of %4.2f\n", gpa);
DAILY ASSIGNMENT D21
The program listed on assignment D20 contains a complete program that includes a header file, defines a class and its two member functions, and has a main program that declares an object that is a member of the class and then invokes (calls) the two member functions to initialize the object and then display its contents.
For assignment D20 you modified the program to replace all of the stdio.h functions with iostream.h objects. For assignment D21, copy d20.cpp to d21.cpp and then, using vedit or other editor, modify d21.cpp as follows:
Add a constructor for the class which takes parameters, and
Add a second object in main initialized with your name, an id# (not necessarily your real one), and a gpa (again not necessarily your real one).
Save the file. Compile, link, test, and if necessary, debug your modified program. When it is working correctly, print the source code file d21.cpp and submit it with this sheet.
DAILY ASSIGNMENT D22
Using the editor built into MATLAB or a text editor such as Notepad, create a MATLAB script M-file containing the commands you used for Part A of assignment D15 along with comments to explain in detail what the script file does. Save the file as d22.m. Then, using MATLAB, run the script file and verify that it performs the same functions as your code for Part A of D15 did. Print out d22.m and submit a copy with this sheet.
For easy reference, Part A of D15 was:
(Part A.) Using MATLAB, create a set of numbers going from 0 to 10 in increments of 0.1 and store it in a vector named A. Using the equation B = 4*A –2.5, define B. Plot B versus A (B on the vertical axis, A on the horizontal axis). Label the axes with their variable names (A and B) and title the plot "Assignment D15 – Your Name, Seat No.". Print out the plot and include it with this sheet.
DAILY ASSIGNMENT D23
Large timber management companies are concerned with reforestation of harvested timberlands. A formula has been developed to compute the acreage reforested in a specified number of years based on the number of acres left uncut and the reforestation rate, which differs for different climates and species. If 1000 acres are left uncut and the reforestation rate is 5% (.05) then at the end on one year 1050 acres (1000+.05*1000) will be forested, and at the end of the second year 1102.5 acres (1050+.05*1050) will be forested.
A. Write a MATLAB function that, when sent the number of forested acres at the start, the reforestation rate and (optionally) the number of years, will calculate and return the number of acres that will be forested. Save your function in an M-file.
B. Write a MATLAB script (save it in a script M-file, d23m) to test the function by using it to calculate the number of forested acres at the end of each year for a user-specified number of years. The user should be prompted to enter the number of acres left after harvesting, the reforestation rate, and the number of years to use in the calculation. Your script should then call the function repeatedly to get the number of forested acres at the end of each year and should display a table showing the initial number of forested acres and the number at the end of each year for the specified number of years.
The MATLAB command rate = input('Enter the reforestation rate >') can be used to get the reforestation rate from the keyboard and similar commands can be use for initial forested acreage and number of years to use.
You have the option of calling your function once and having it calculate and return a matrix containing data for each of the selected number of years or calling the function for each year and having it return the data for that year. The sample fprintf statements below assume doing the latter.
The MATLAB command fprintf('Year forested acres\n') can be used for column headings for the table.
The MATLAB command fprintf('start %10.1f\n',acres) can be used to display the initial conditions.
The MATLAB command fprintf('%3d %10.1f\n',year,acres) can be used to display the data for each year.
Print your script file, d23.m, your function file, and the results that were displayed in the MATLAB command window and submit them with this sheet.
DAILY ASSIGNMENT D24
An existing data file d10.dat in the common area contains measured diameters of 20 wristpins. You will need to transfer this file from the UNIX workstation to your PC. Write a complete MATLAB program (as a MATLAB script M-file) to read all of the data, compute the average and standard deviation, determine the number of parts whose diameter varies by more than one standard deviation from the average, and display the results in the MATLAB Window. The formula for computing standard deviation is given below:
Include your name, table number, and section as a MATLAB comment statement in your script file. Save your file as d24.m. Print out your script file and a copy of your results and submit those printouts with this sheet.
DAILY ASSIGNMENT D25
Elastic cables AC and BC are attached to a solid rod AB of length a. Depending on the position of end A, the angle θ between the two cables will change. The angle between these two cables can be defined using the vector scalar product (also known as the dot product). A relatively simple calculation shows that the angle can be defined as:
Write a MATLAB script that will determine the angle θ as a function of the x coordinate and the length of rigid rod AB. Save your script as d25.m
Plot θ versus x with , for rod lengths of a = 15”, 20” and 25”.
When your script is working and producing correct results, print the script and the plot and submit them with this sheet.