Question

Give the command that would be typed in MATLAB to define a variable X as the...

Give the command that would be typed in MATLAB to define a variable X as the sine of 30 degrees. Use proper syntax.

Give the command that would calculate the inverse tangent of (y/x) and give degrees. Use proper syntax.

Explain when the period (.) is needed before a * or / or ^ when writing code in MATLAB. Be specific and give an example.

Explain what a MATLAB function is, what components are required, and why they are useful.

Write out by hand a MATLAB function, USING PROPER SYNTAX, that will calculate the volume of a box, given the length, width, and height as input arguments.

Homework Answers

Answer #1

1.
Use command: X = sind(30)

2.
Use the command:  atand(y/x)

3.
'.' is needed when we want to perform element-wise operations in matrices or arrays.
For example, if we wan to multiply 3 to each element of a given matrix A.

Suppose A = [1 2 3; 4 5 6; 7 8 9],

Then we just write 3.*A,
this will give a matrix whose every element is multiplied by 3.

4.

A Matlab function can be seen as a set of commands or line of codes which are written together to perform some specific task.
Functions can take input arguments and they may or may not return something.

Functions are separate from the other codes.
In Matlab, we have to create separate .m files for writing the functions.

5.

disp(volumeOfBox(5, 5, 5)); % function call

function vol = volumeOfBox(l, b, h) % function definition

vol = l*b*h; % calculate the volume and store in vol

end

FOR HELP PLEASE COMMENT.
THANK YOU,

Know the answer?
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
Similar Questions
Recall that the command diff(f(x),x) symbolically finds the derivative of the function f. Recall also that...
Recall that the command diff(f(x),x) symbolically finds the derivative of the function f. Recall also that the derivative is itself a function which can also be differentiated, giving us the second derivative of f, and so on. MATLAB will easily compute higher order derivatives using the command diff(f(x),x,n) Where n represents which derivative you want. Later, it will be very useful to find patterns in higher order derivatives. Ordinarily, this is most easily done by NOT simplifying the resulting expression,...
Write a Matlab program to plot the cosine wave. That is plot y=cos(k1x) vs. x for...
Write a Matlab program to plot the cosine wave. That is plot y=cos(k1x) vs. x for x varying from 0 to 2pi radians. The value of k1 is given at the end of this document. You can choose the increment for x. Note that large values of the increment will give you a coarse graph. Note: Matlab has two functions to calculate the sine of an angle: sin(x) and sind(x). What is the difference between these two functions? Use help...
I did already posted this question before, I did get the answer but i am not...
I did already posted this question before, I did get the answer but i am not satisfied with the answer i did the code as a solution not the description as my solution, so i am reposting this question again. Please send me the code as my solution not the description In this project, build a simple Unix shell. The shell is the heart of the command-line interface, and thus is central to the Unix/C programming environment. Mastering use of...
1. Vim commands: a. How do you auto indent your program? b. Explain what the following...
1. Vim commands: a. How do you auto indent your program? b. Explain what the following commands do: dd, y3, p, :set cindent (1 pt) VIM exercises These exercises on the computer need to be repeated by each student in the pair. This is to ensure that both students understand how to get around in Linux!!! For this part of the lab, you will create a .vimrc file that will help you develop your C++ programs using VIM. First, we...
Leave comments on code describing what does what Objectives: 1. To introduce pointer variables and their...
Leave comments on code describing what does what Objectives: 1. To introduce pointer variables and their relationship with arrays 2. To introduce the dereferencing operator 3. To introduce the concept of dynamic memory allocation A distinction must always be made between a memory location’s address and the data stored at that location. In this lab, we will look at addresses of variables and at special variables, called pointers, which hold these addresses. The address of a variable is given by...
3.   Consider the following data set for an office structure built by Anderson Construction Co. The...
3.   Consider the following data set for an office structure built by Anderson Construction Co. The completed building is nine stories. However, construction was interrupted by a fire after 5.3357 floors were completed. At the time of the fire, Anderson had used 54,067 hours of labor to construct the first 5.3357 stories of the building. It then took Anderson an additional 40,750 labor hours to complete this nine-story building. In this problem, FLRCOM is the number of floors completed, and...
PYTHON : Create a Email Address Parser (* Please do make comments*) Often times, you may...
PYTHON : Create a Email Address Parser (* Please do make comments*) Often times, you may be given a list of raw email addresses and be asked to generate meaningful information from such a list. This project involves parsing such a list and generating names and summary information from that list. The script, eparser.py, should: Open the file specified as the first argument to the script (see below) Read the file one line at a time (i.e., for line in...
True or false? A larger sample size produces a longer confidence interval for μ. False. As...
True or false? A larger sample size produces a longer confidence interval for μ. False. As the sample size increases, the maximal error decreases, resulting in a shorter confidence interval.True. As the sample size increases, the maximal error decreases, resulting in a longer confidence interval.    True. As the sample size increases, the maximal error increases, resulting in a longer confidence interval.False. As the sample size increases, the maximal error increases, resulting in a shorter confidence interval. True or false? If the...
Consider the C program (twoupdate) to demonstrate race condition. In this assignment, we will implement Peterson's...
Consider the C program (twoupdate) to demonstrate race condition. In this assignment, we will implement Peterson's algorithm to ensure mutual exclusion in the respective critical sections of the two processes, and thereby eliminate the race condition. In order to implement Peterson's Algorithm, the two processes should share a boolean array calledflagwith two components and an integer variable called turn, all initialized suitably. We will create and access these shared variables using UNIX system calls relating to shared memory – shmget,...
For this assignment you will implement a simple calculator or interpreter that reads arithmetic expressions from...
For this assignment you will implement a simple calculator or interpreter that reads arithmetic expressions from a file. Specifically, you will implement the following function: /* * Reads one arithmetic "expression" at a time from a file stream, computes, then * returns the result. If there are additional expressions in the file, they are * read and computed by successive calls to “calculator”. * * “Expressions” are groups of operations (add, subtract, multiply, divide). Your * calculator will read and...