Question

Assignment: Do this assignment after reading zyBooks Chapter 3. Create the following functions in MATLAB and...

Assignment: Do this assignment after reading zyBooks Chapter 3. Create the following functions in MATLAB and save them to your directory. You must use the function names provided below! Use the attached test script TestConversions.m to test your functions.

kmout = MilesToKm(miles) % converts a value in miles to kilometers
JoulesOut = CalToJoules(DietaryCalories) % converts dietary calories (big calories) to Joules
kWhrOut = JoulesToKWHr(joules) % converts Joules to kilowatt hours
metersout = FeetToMeters(feet) % converts feet to meters
secondsout = HoursToSeconds(hours) % converts hours to seconds

Each of the functions must follow good programming practices, including appropriate help comments that will respond to MATLAB’s help command.

Submission: Execute the test script TestConversions If your functions do not handle array inputs, modify TestConversions to create appropriate loops. Publish TestConversions, its outputs, and each of your files to PDF form and submit them per
the instructions received in discussion. A single output PDF containing all of the information is preferred, but separate files will be accepted.
* please show me screenshots if possible and test it to make sure it works. Thank you!

0 0
Add a comment Improve this question Transcribed image text
Answer #1

PLEASE REFER BELOW CODE

1) CREATE MilesToKm.m AND PASTE BELOW CODE

function kmout=MilesToKm(miles)
kmout = miles / 0.62137;
end

2) CREATE CalToJoules.m AND PASTE BELOWCODE

function JoulesOut = CalToJoules(DietaryCalories)
JoulesOut = DietaryCalories / 4184 ;
end

3) CREATE JoulesToKWHr.m AND PASTE BELOW CODE

function kWhrOut = JoulesToKWHr(joules)
    kWhrOut = (joules * 10^7) / 2.777778 ;
end

4) CREATE FeetToMeters.m AND PASTE BELOW CODE

function metersout = FeetToMeters(feet)
    metersout = feet / 3.2808;
end

5) CREATE HoursToSeconds.m AND PASTE BELOW CODE

function secondsout = HoursToSeconds(hours)
    secondsout = hours * 3600;
end

6) CREATE TestConversions.m AND PASTE BELOW TEST CODE.

close all
clear all
clc


kmout=MilesToKm(100)
JoulesOut = CalToJoules(4000)
kWhrOut = JoulesToKWHr(900)
metersout = FeetToMeters(200)
secondsout = HoursToSeconds(7)

PLEASE REFER BEOW OUTPUT


kmout =

160.9347


JoulesOut =

    0.9560


kWhrOut =

   3.2400e+09


metersout =

   60.9607


secondsout =

       25200

>>

Add a comment
Know the answer?
Add Answer to:
Assignment: Do this assignment after reading zyBooks Chapter 3. Create the following functions in MATLAB and...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • part 1: Create Useful Functions. Create the following functions in MATLAB and use the function names...

    part 1: Create Useful Functions. Create the following functions in MATLAB and use the function names provided below! kmout = MilesToKm(miles) % converts a value in miles to kilometers kJoulesOut = CalTokJoules(DietaryCalories) % converts dietary calories (big calories) to kiloJoules (10^3 Joules = 1 kJ) kWhrOut = KJoulesToKWHr(Kjoules) % converts kJoules to kilowatt hours kmout = FeetTokm(feet) % converts feet to kilometers secondsout = HoursToSeconds(hours) % converts hours to seconds Each of the functions includ appropriate help comments that will...

  • This script will create a dictionary whose keys are all the directories listed in thePATH system...

    This script will create a dictionary whose keys are all the directories listed in thePATH system variable, and whose values are the number of files in each of these directories. The script will also print each directory entry sorted by directory name. The script will use the following five functions to get the required results get_environment_variable_value() get_dirs_from_path() get_file_count() get_file_count_for_dir_list() print_sorted_dictionary() get_environment_variable_value() The header for this function must be This function must accept a shell variable as its only parameter The...

  • Tokeniser in C++

    TokenisersBackgroundThe primary task of any language translator is to work out how the structure and meaning of an input in a given language so that an appropriate translation can be output in another language. If you think of this in terms of a natural language such as English. When you attempt to read a sentence you do not spend your time worrying about what characters there are, how much space is between the letters or where lines are broken. What...

  • Purpose: Demonstrate the ability to create and manipulate classes, data members, and member functions. This assignment...

    Purpose: Demonstrate the ability to create and manipulate classes, data members, and member functions. This assignment also aims at creating a C++ project to handle multiple files (one header file and two .cpp files) at the same time. Remember to follow documentation and variable name guidelines. Create a C++ project to implement a simplified banking system. Your bank is small, so it can have a maximum of 100 accounts. Use an array of pointers to objects for this. However, your...

  • I am a beginner in shell. Please help me with this question. question: In this assignment,...

    I am a beginner in shell. Please help me with this question. question: In this assignment, you will research into a few standard Unix utilities and leverage them in a shell script to perform a simple but useful task that's right up the alley of Unix shell scripting. As usual, you should aim for reasonably efficient algorithms and reasonably organized, comprehensible code. Consolidating log files My Internet chat software recording my conversations into daily log files, each named by date,...

  • Q.5] Answer the following questions based on the company database (based on the homework assignment 2) y dat...

    Q.5] Answer the following questions based on the company database (based on the homework assignment 2) y database (based on the homework assignment 2) 3 IPage 1. For each department whose average employee salary is more than $30,000, write a SQL statement to retrieve the department name and the number of employees working for that department 2. Write a SQL statement to retrieve first name, last name, and address of each employee who lives in Houston, TX. 3. Write a...

  • n this programming assignment, you need to create 3 files. 1. DateType.h 2. DateType.cpp 3. A...

    n this programming assignment, you need to create 3 files. 1. DateType.h 2. DateType.cpp 3. A test driver for testing the class defined in the other 2 files. You can name your file in the way you like. Remember it must be a .cpp file. In DateType.h file, type these lines: // To declare a class for the Date ADT // This is the header file DateType.h class DateType { public: void Initialize(int newMonth, int newDay, int newYear); int GetYear()...

  • You shall write a very basic web server in Javascript that will run via nodejs. Your...

    You shall write a very basic web server in Javascript that will run via nodejs. Your project shall include the following line: var paul   = require('/homes/paul/HTML/CS316/p3_req.js'); Your project will accept HTTP requests via URLs in the following format:       /[a-zA-Z0-9_]*.cgi Here are the steps you must perform for .cgi URLs: 1) call http .createserver(myprocess) my process() is a function you will write to process requests from the user via their browser 2) create a mylisten() function that takes the following parameters:...

  • Please help me with the following question. This is for Java programming. In this assignment you are going to demonstrate the uses of inheritance and polymorphism. You will create an Animals class and...

    Please help me with the following question. This is for Java programming. In this assignment you are going to demonstrate the uses of inheritance and polymorphism. You will create an Animals class and a Zoo class that holds all the animals. You should create a general Animalclass where all other classes are derived from (except for the Zoo class). You should then create general classes such as Mammal, Reptile, and whatever else you choose based off of the Animalclass. For...

  • OUTCOMES After you finish this assignment, you will be able to do the following: Define an...

    OUTCOMES After you finish this assignment, you will be able to do the following: Define an abstract class Create concrete classes from an abstract class Overload an operator Split classes into .h and .cpp files Open files for reading Write to files Use output manipulators such as setw, fixed, and setprecision DESCRIPTION A binary arithmetic operation takes two double operands (left and right) to perform addition, subtraction, multiplication, or division on. For example, 10 + 11 is an addition (+)...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT