Write a Scilab script that takes no inputs and displays the following informatio
ID: 2080387 • Letter: W
Question
Write a Scilab script that takes no inputs and displays the following information.
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’.
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’.
Hint, use the following sciLab equation
Y=-0.45*X.^2+9.5*X
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.
Explanation / Answer
Scilab Code:
clc;
clear all;
X = 0:0.5:20;
disp(X);
Y = (-0.45*X.^2)+(9.5*X);
disp(Y);
[I,M]=max(Y);
disp('Index where maximum value');
disp(I);
disp('Maximum value');
disp(M);
Command window output:
Columns 1 through 5
0 0.5000 1.0000 1.5000 2.0000
Columns 6 through 10
2.5000 3.0000 3.5000 4.0000 4.5000
Columns 11 through 15
5.0000 5.5000 6.0000 6.5000 7.0000
Columns 16 through 20
7.5000 8.0000 8.5000 9.0000 9.5000
Columns 21 through 25
10.0000 10.5000 11.0000 11.5000 12.0000
Columns 26 through 30
12.5000 13.0000 13.5000 14.0000 14.5000
Columns 31 through 35
15.0000 15.5000 16.0000 16.5000 17.0000
Columns 36 through 40
17.5000 18.0000 18.5000 19.0000 19.5000
Column 41
20.0000
Columns 1 through 5
0 4.6375 9.0500 13.2375 17.2000
Columns 6 through 10
20.9375 24.4500 27.7375 30.8000 33.6375
Columns 11 through 15
36.2500 38.6375 40.8000 42.7375 44.4500
Columns 16 through 20
45.9375 47.2000 48.2375 49.0500 49.6375
Columns 21 through 25
50.0000 50.1375 50.0500 49.7375 49.2000
Columns 26 through 30
48.4375 47.4500 46.2375 44.8000 43.1375
Columns 31 through 35
41.2500 39.1375 36.8000 34.2375 31.4500
Columns 36 through 40
28.4375 25.2000 21.7375 18.0500 14.1375
Column 41
10.0000
Index where maximum value
50.1375
Maximum value
22
>>
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.