Scilab Assignment
ENGR 112 HW#7 NAME________________________
For this Homework you will be creating scripts in SciLab. You will need to turn in the files you create (scinotes files) when you turn in the homework.
1.) Write a Scilab script named HW7_Prob_01.sce, that takes no inputs and returns the vectors below.
1. Use the colon operator to create a vector starting with -50 and ending with 10 in increments of 2. (+2 points)
2. Use the linspace function to create a vector of length 9 that is linear spaced from 100 to 175. (+2 points)
2.) For this problem you will be learning how to use Scilab to do calculations. Write a Scilab script named HW7_Prob_02.sce, that takes no inputs and displays the following information.
1. Use the colon operator or the linspace() function to create a row vector named ‘X’ that goes from 0 to 20 in increments of 0.5. Use the disp() function to display the vector ‘X’. (+3 points)
2. Using the mathematical equation Y= -0.45X2+9.5X, to calculate the result of ‘Y’ for each of the ‘X’ values. Use the disp() function to display the vector ‘Y’. (+4 points)
· Hint, use the following sciLab equation
· Y=-0.45*X.^2+9.5*X
3. Use the max() function to find the peek point of ‘Y’ and the location of the peek point. Use this information to find the corresponding ‘X’ value. Use the disp() function to display the peek and the corresponding ‘X’ value. (+4 points)
3.) Write a Scilab script named HW7_Prob_03.sce, that creates 2 tables.
a. Table 1 will convert °F to K
i. Request the user to input the number of elements you want in a vector. Call this variable “Increment1”. (+1point)
ii. Use the linspace function to create a vector from 0°F to 200°F and uses the number of elements input by the user in the following formula (200/”increment1”)+1. Name this variable “F”. (+2 points)
iii. Use the formula (5/9)*(F +459.67) to create a vector of K values. Name this variable “K”. (+2 points)
v. Display A (+1 point)
b. Table 2 will convert °C to °R
i. Request the user to input the starting temperature. Name this variable “StartTemp”. (+1 point)
ii. Request the user to input the increment of the table (e.g., five degrees, 10 degrees, 20 degrees, etc between start temp and second value.) Name this variable “increment2”. (+1 point)
iii. Use the linspace function to create a vector from “StartTemp” to (StartTemp+24)*increment2, with an increment equal to “increment2”. Name this Variable “C”. (+2 points)
iv. Use the formula (9/5)*C+491.67 to create a vector of R values. Name this variable “R”. (+2 points)
v. Concatenate C and R into a 2 row matrix (such that C values are directly on top of R values). Name this variable “B”. (+1 point)
vi. Display B (+1 point)
4.) (Extra Credit) Write a Scilab script named HW7_Prob_04.sce, that will take in any size vector and return the following information: (+8 points)
· The sum of the values in the vector
· The smallest number in the vector and its location
· The largest number in the vector and its location
· The average of the vector
· The length of the vector
· The transposed version of the vector
· A 1x2 vector containing the first and last value of the vector