Question: MAT LAB: write a program that can choose from an assortment of calculations and perform the desired physics calculation in order to streamline the design

MAT LAB:

write a program that can choose from an assortment of calculations and perform the desired physics calculation in order to streamline the design and modelling process.

Your function should take three inputs in the following order: var1 The first number in the calculation you want to perform. var2 The second number in the calculation you want to perform var3 The third number in the calculation you want to perform indicator . A variable, that has a data type of your choice , that the user will use to determine which operation to perform. You should note in a comment how you are implementing the indicator variable.

Your function should have one output, result. Your function should be able to perform the following operations, and should assume SI units for each input:

Distance. Given var1 as a 1-dimensional acceleration, and var2 as 1-dimensional velocity, and var3 as time, determine result via the formula:

= * 1/2 ^2

Work. Given var1 as a force, var2 as a distance an object moved, and var3 as the angle between the force and the direction of movement (in radians), determine result via the formula:

= cos()

Falling object velocity: Given var1 as an initial speed and var2 as an amount of time, and var3 as the force of gravity acting upon the object, calculate the result via the formula:

= +

Torque. Given a var1 as a force acting upon an object with a fixed axis of rotation, var2 as a distance away from the axis of rotation, and var3 as the angle of the force with respect to the parallel along which the distance was measured, calculate the result via the formula:

= sin()

Note that every time this function is called, it should only perform one of these calculations. However, the user should be able to choose from any of the calculations with each call using the indicator input. If a user calls your function with an indicator value that is not associated with anything, please return a string with a message indicating this as your output instead of the result of a calculation.

Thanks!

It would be great if this was written with: if else/while/for statements (just bc that is what we have covered in class!)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!