Publicidad

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

wviola
3 de Feb de 2023
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
Próximo SlideShare
Matlab graphicsMatlab graphics
Cargando en ... 3
1 de 2
Publicidad

Más contenido relacionado

Más de wviola(20)

Publicidad

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
Publicidad