Question: Create a function (in a function m-file) that has one input. No outputs will be returned. The input will be a vector. The function should
Create a function (in a function m-file) that has one input. No outputs will be returned. The input will be a vector. The function should compute the square of each element of the input vector. First, this function should print the input numbers and their squares to the Command Window in two columns, with the input numbers in the first column and the squares in the second column. All numbers should be printed as integers. (In other words, no decimal points should be printed.) Both columns should have right justification. (In other words, the least significant digits should line up vertically) Second, the function should plot the squares as a function of the input vector. For instance, if the first value was 0.5, first point of the plot should be (0.5.0.25). The plot should be made with smooth lines. Prepare a script. This script should create a vector of integers, starting at 1 and ending at 10 in increments of 1. Call your function with this vector as input
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
