Anzeige
Again I need some help writing them! 1- In this problem you are asked.docx
Again I need some help writing them! 1- In this problem you are asked.docx
Nächste SlideShare
Matlab graphicsMatlab graphics
Wird geladen in ... 3
1 von 2
Anzeige

Más contenido relacionado

Más de wviola(20)

Anzeige

Último(20)

Again I need some help writing them! 1- In this problem you are asked.docx

  1. Again I need some help writing them! 1. In this problem you are asked to develop a matlab function that will calculate the velocity of a ball when it hits the ground, if the ball is dropped from a height "h" above the ground. You should have the following function format: [Velocity] = Ball_Drop(Height) 2. recreate a function that takes any length vector x of values, eg: x = [1 1.3 2 2.3 4] and calculate the average value and product of these vector values. You may not use the built-in "average" or "product" functions in matlab. The function should have the following input/output variables and should be saved as getAverageProduct.m: [averageVal, product] = getAverageProduct(x) Solution The matlab codes are 1. function velocity = Ball_Drop(height) g = 9.8; velocity = sqrt(2*g*height); end 2. function [averageVal,product] = getAverageProduct(x) product = 1;
  2. n = size(x,2); averageVal = sum(x)/n; for i=1:n product = product*x(i); end end
Anzeige