145k views
2 votes
Create a user-defined function that computes a ligament force value for Lecture 8 - Problem 9. For the function name and arguments use [fone] ] lay__name_ligament ( _zerm, __linearslope,lengpb) From your homework file, call the user-defined function to compute force values for a range of ligament lengths between 20 mm and 40 mm, every 1 mm. L-em =25 mm, / linear=30 mm, and slope =100 N/mm. Follow these instructions: - Call the function inside of a for loop in your homework file using 20≤ length ≤40. - Remove the fprintf command from the progmam. Problem 8 Create a user-defined function that computes a sin(x) Lecture 8 - Problems 5 and 6 . The user must enter a choice between 1 and 2 . If 1 , the solution will be done using for loop. If 2 , the solution will be done using while loop. Answer must be in the form: The sin of is. wing loop, wbid prorides an emor equal to - Use scientific notation with 2 deaimal places. For the function name and arguments use D= last_name_sine(choice)

1 Answer

3 votes

Final answer:

The user-defined function lay__name_ligament calculates the ligament force, called within a for loop for lengths ranging from 20 mm to 40 mm. Another function, last_name_sine, computes sin(x) using a for or while loop based on user input, outputting in scientific notation with two decimal places.

Step-by-step explanation:

Computing Ligament Force and Sine Function

To compute the ligament force value, we first define a user-defined function lay__name_ligament that calculates the force based on the provided variables (_zerm, __linearslope, lengpb). This function likely represents a biomechanical model where the variables stand for parameters such as zero-force length of the ligament (_zerm), the linear region's slope of the force-elongation curve (__linearslope), and the length of the ligament being tested (lengpb). To calculate force values across a range of ligament lengths, call this function in a loop that iterates from 20 mm to 40 mm.

For the second problem, the last_name_sine function calculates sin(x) either in a for loop or a while loop depending on the user's choice. The function returns the sine of the input in scientific notation with two decimal places.

It's important to remember when writing functions in programming to follow the instructions on the use of loops and output formats accurately. This helps to ensure that your code is efficient and effective in solving the given problems.

User Tomsseisums
by
7.5k points