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

  How many words are required for physical memory

A system has a virtual memory space of 8 virtual pages for a process with 4 blocks per page and 8 words per block. The main memory consists of 8 page frames with 4 blocks per page and 8 words per block. How many words are required for physical mem..

  The difference between a conventional torus and folded torus

Explain the graph theoretic relationship among k-ary n-cube network and rings meshes tori binary n-cubes and omega networks.

  Compute the value of n after operating the system

The system gets updates 10 times per second, and thusstores in memory the (integer) number of 0.1 s that have elapsed since the system was turned on.

  Build a program to implement the selection sort algorithm

build a program to implement the selection sort algorithm, which will sort a list of strings. Selection sort function should sort the list of strings in alphabetical order. You only need to provide the details for the selectionSort() function base..

  What is a spreadsheet circular reference

How does copying formulas down a row or across a column sometimes help us set up a spreadsheet? What is a spreadsheet circular reference? Why is it a problem?

  Make a single table to hold all of the information

discuss a typical sales invoice that would include the following information. Design a single table to hold all of the information required to store an invoice including this information.

  The cost of building and maintaining an organizational

the cost of building and maintaining an organizational computing ecosystem has become a bigger part of most

  In this assignment you will learn to use a new technology

we are all socially connected. some of us like to be so more than others. technology allows us to do this in a variety

  Find the mean height of the basketball players

Following are heights, in inches, for a sample of college basketball players. Find the mean height of the basketball players.

  How the adoption of the technology affects

Your mandate as VP of Technology is to keep the regular projects strong and growing, plan for TechnoSeniors, and overhaul the AllTechComm intranet. Your must make the intranet one in which volunteers could sign up and manage their schedules, profi..

  Encode and post the picture with a hidden message

Encode and post the picture with a hidden message. That means do not get hung up on one "encoded picture." Try next one. If somebody was not able to decode your message, first make sure at least you can do it.

  Why would a network administrator use wireshark

Why would a network administrator use Wireshark and NetWitness Investigator together? When the 172.16.8.5 IP host responded to the ICMP echo-requests, how many ICMP echo-reply packets were sent back to the vWorkstation?

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