Question
The force required to compress a linear spring is given by the equation F = kx where F is the force (N), and k is
The force required to compress a linear spring is given by the equation
F = kx
where F is the force (N), and k is the spring constant (N/m).
The potential energy stored in the compressed spring is given by the equation E = 12kx2
where E is the energy (J).
The following information is available for 4 springs; the values in the table below are provided in the file springs.txt (or springs.dat) on Blackboard where each row represents a spring.
Spring 1 Force (N) 20
Spring constant, k (N/m) 200
Spring 2 30 250
Spring 3 25 300
Spring 4 20 400
Write a MATLAB program to read in the information from the file and to calculate the potential energy stored in each spring. Rather than reading each value one at a time as was done in the first problem, read all the data into a single matrix. Print a table of the results resembling the table above that contains the force, spring constant, and potential energy for each spring to a new file. Be certain that the table is captioned appropriately. (Hint: Look at help fprintf for information about printing in a table format.) Submit the .m file and the output file.
Question hints given:
One thing that you will learn later in MATLAB is that MATLAB sees all variables as matrices. If I have two vectors with the same number of values (e.g., Example 3 in Lecture 7) say X and Y, then Z=X.*Y will set the first value in Z as the product of the first value in X and Y, the second in a similar fashion, and so on. Also If one wants to square all the values in a vector, then Z=X.^2 will place the square of the first element in X in the first element of Z and so on. Once again, be mindful of units. Remember (CNN) -- NASA lost a $125 million Mars orbiter because a Lockheed Martin engineering team used English units of measurement while the agency's team used the more conventional metric system for a key spacecraft operation, according to a review finding released Thursday. http://www.cnn.com/TECH/space/9909/30/mars.metric.02/#:~:text=(CNN)%20%2D%2D%2 0NASA%20lost%20a,a%20review%20finding%20released%20Thursday. An answer without appropriate units is always WRONG (unless it is a non-dimensional quantity).
Problem 2: The force required to compress a linear spring is given by the equation F = kx where F is the force (N), and k is the spring constant (N/m). The potential energy stored in the compressed spring is given by the equation E = Ykx where E is the energy (J). The following information is available for 4 springs; the values in the table below are provided in the file springs.txt (or springs.dat) on Blackboard where each row represents a spring. Spring 1 Spring 2 Spring 3 Spring 4 Force (N) 20 30 25 20 Spring constant, k (N/m) 200 250 300 400 Write a MATLAB program to read in the information from the file and to calculate the potential energy stored in each spring. Rather than reading each value one at a time as was done in the first problem, read all the data into a single matrix. Print a table of the results resembling the table above that contains the force, spring constant, and potential energy for each spring to a new file. Be certain that the table is captioned appropriately. (Hint: Look at help fprintf for information about printing in a table format.) Submit them file and the output fileStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started