Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1. Write a script as a user-defined function with the function name of Cal_PE_[YOUR WSU ID), which enables to calculate the potential energy of an
1. Write a script as a user-defined function with the function name of Cal_PE_[YOUR WSU ID), which enables to calculate the potential energy of an object in Joule, by receiving two inputs, i.e., one for the mass, m (in kg), and the other for height, h. NOTE: you need to save this script as Cal_PE_[YOUR WSU ID].m (replace [YOUR WSU ID with your WSU ID, e.g., A111B222, to be recognized as an executable function by Octave (or Matlab). You may want to review an article (especially for gravitational potential energy) to solve the problem (https://en.wikipedia.org/wiki/Potential_energy). What is the potential energy of the mass, m = 2 kg, and height, h = 5 m? You need to calculate the potential energy in the command window by calling your function, Cal_PE_[YOUR WSU ID) (see the templates below) (1 pt) Template for the Octave (or Matlab) function writing in a script editor function PE = Cal_PE_[YOUR WSU ID] (m, n) [YOUR SCRIPT SHOULD BE GIVEN HERE] end Template for the Octave (or Matlab) function calling in a command window >> m = 2; h = 5; PE = Cal PE [YOUR WSU ID](m, h)
Step 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