A function magnitude that computes the magnitude of a vector

Assignment Help Computer Engineering
Reference no: EM132199052

a) Write a function magnitude that computes the magnitude of a vector, i.e., the square- root of the sum of the squares of the components of the vector.

b) Write a function inner_prod that computes the inner product (i.e., dot product) of two vectors.

c) Write a function num_to_month that computes the string name of the month from an input integer from 1 to 12. The behavior on another input is unspecified.

d) Write a predicate (a function that returns true or false) is_divisible that takes two integers and determines whether the first is divisible by the second, return true in that instance and false otherwise.

e) Write a predicate is_leap_year that determines whether a year, given as a positive

number is a leap year or not. Use is_divisible and the following rules in order:

i) If the year is not evenly divisible by 4, then it is NOT a leap year.

ii) If the year is evenly divisible by 4, but not 100, then it is a leap year.

iii) If the year is evenly divisible by 400, then it is NOT a leap year, otherwise it is a

leap year.

f) Write a function cross_prod that computes the cross product of two length-three vectors. (Do not use a built-in MATLAB functions to accomplish this.)

g) Write a function called pair that takes two numbers x and y and returns a vector of length two with x in the first cell and y in the second cell.

h) Write a function components that computes the horizontal and vertical components of a vector specified by a positive length and an angle in degrees (counter-clockwise from the positive x-axis). Your function should return two values: the x-component of the vector, then the y-component.

i) Write a function components_vec that performs the same computation as in the previous question, but instead returns a vector of length two with the same results. Use the function pair you wrote above.

j) Write a function average_point that takes three vectors xs, ys, zs of length n and computes the average of the n points described by these vectors. If not all vectors are the same length return the point (0, 0, 0). This function returns a vector of length 3.

k) Trace the following code:

clear; clc; x = 0;
y = 15
z = 30;

x = run_test(z);

function y = run_test(x) y = x;

x = pi; end

Reference no: EM132199052

Questions Cloud

Find the equation of typical firm short-run supply function : A typical perfectly competitive firm in industry Y has the following short-run cost function. (Note: The answer to this question must be hand-written.)
Potential for resale among customers : Consider sanitizing body wipes, please devise a price discrimination scheme intended to increase total sales revenue. Response to this question
The average of the even elements of the array : Write a function double average(int arr[] , int n), that returns the average of the even elements of the array.
What pressure is placed on the current spot exchange rate : If these two investors' decisions are typical of other investors in the U.S. and U.K., what pressure is placed on the current spot exchange rate?
A function magnitude that computes the magnitude of a vector : Write a function magnitude that computes the magnitude of a vector, i.e., the square- root of the sum of the squares of the components of the vector.
Supply and demand curve for the coffee market : 1. How does Elasticity of demand relate to coffee prices and the current coffee market?
Write a function to decrypt a message : Write a function to decrypt a message that was encrypted using the Affine cipher .
What is a corporate merger : What is a corporate merger? What is an acquisition? What is the goal of antitrust policies?
How a utilitarian would prefer to redistribute wealth : Suppose we start out with an allocation “down and to the right” on your diagram, where Group A has most of the wealth and hence most of the utility.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd