Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Simple Programming Exercises In the following exercises, you must write matlab code from scratch. You are not permitted to use any built in functions other

Simple Programming Exercises

In the following exercises, you must write matlab code from scratch. You are not permitted to use any built in functions other than mathematical functions like sin(x), cos(x), exp(x),sqrt(x), etc.

With the exception of problem 2, you may use the length and size commands to obtain the size of the matrix or vector.

1. Discrete representations of functions and plotting

(a) Write a function that will take a vector x = [x1 x2 xn], of arbitrary length, as an input and will output a vector y = f(x1) [f(x2) f(xn)] where f(x) = (x^2*e^?2x) + cos(3x)/sqrt[1 + x]

(b) Create a vector x consisting of 1000 evenly space points on the interval [10, 50] and use your function from part

(a) to create a vector y ]=[ f(10) f(50) . Then using x and y, create a plot of y = f(x).

2. For Loops with Iterative Addition Define a function that will take a vector x = [x1 xn] as an input and will output the length of the vector y = ||x|| = sqrt [(x1)^2 + (x2)^2 + + (xn)^2] . Use a For Loop for this. To avoid having to determine the length of the vector (for reaching a stopping point in the loop), you can use the vector itself for the index of the for loop. For example, your for loop can start out as for i=x

3. For/While Loops with Iterative Multiplication

(a) Write a function that will take a positive integer n as an input and output the factorial y = n! = n(n ? 1)(n ? 2) 2 1 using a For Loop.

(b) Repeat part (a) using a While Loop

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals, Design, and Implementation

Authors: David M. Kroenke, David J. Auer

14th edition

133876705, 9781292107639, 1292107634, 978-0133876703

More Books

Students also viewed these Databases questions

Question

What does Processing of an OLAP Cube accomplish?

Answered: 1 week ago