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.
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,
Get Answers For Free
Most questions answered within 1 hours.