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

  Write a program that allows to examine effects of array size

Write a program that allows you to examine the effects of array size and initial data order when your favorite sort operates on an array of integers.

  Create a data type using a doubly-linked circular structure

In this lab, using C++, you will create an abstract data type, using a doubly-linked circular structure to store the values and links.

  Evaluate in gf polynomial

Evaluate in GF(2^8): (x^4+x+1)/(x^7+x^6+x^3+x^2), where the irreducible polynomial is the one used by AES, P(x)=x^8+x^4+x^3+x+1.

  Would the greedy algorithm remain optimal for giving change

TV anchor Greta Van Susteren suggested that we should leave Jackson on the $20 bill and instead create a new $25 bill featuring Tubman.

  Develop an online document library

Develop an online document library - create an application with the following architecture - Dockerfile exposes different ports for different APIs

  Why it is necessary to use database system

Why it is necessary to use database system? What kinds of information this database system collect? and what information it provides?

  Create an array of doubles and somehow put values into it

Display the array before sortingcall sort to sort the arraycall show to display the array after sortingFor this program.

  Explain requirements of the security policy statement

Please select an appropriate hardening technique to meet the requirements of the security policy statement. Provide rationale for each selection.

  What is storage capacity and how is that capacity organized

Is FAT used, or another approach? What is the storage capacity? How is that capacity organized? (Partitions? Tracks? Sectors?).

  Write down english narrative that converts currency

Using the C compiler, write down a C program that contains your narrative from broken down into one line sentences, that have been commented out.

  What is the ip address of your workstation

If you have access to the Internet at work, school, or home, what is the IP address of your workstation? Explain your reasoning.

  What are multiprogramming and multithreading

What are multiprogramming and multithreading? List Two advantages of user level threads (ULTs) over kernel level threads (KLTs).

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