1. Вычислите значения функции
в точках 0.2, 0.3, 0.5, 0.8, 1.3, 1.7, 2.5, 5, k. Где k - численное значение выражения, заданного табл. 1 и 2.
2. Сформируйте вектор-строку v, содержащую все значения аргумента x и последние пять значений функции y(x).
3. Получите вектор-строку v1, добавив к каждому элементу вектора-строки v число 2.1.
Таблица 1
0 или 5 |
|
Таблица 2
4. Вычислите: w= v + v1; w1 = v - v1; w2 = v1- v; w3 = v ./ v1; w4 = v1.*v; w5 = v1.^v.
5. Упорядочите результаты сложения векторов v + v1 в порядке:
- возрастания модулей элементов вектора суммы;
- возрастания элементов вектора суммы;
- убывания элементов вектора суммы.
6. Сформируйте из третьих и пятых элементов векторов-строк w, w1, w2, w3, w4, w5 вектор-столбец ww.
7. Определите в векторе ww минимальный и максимальный элемент, сумму и произведение компонент вектора.
8. Присвойте элементам массива wwс третьего по шестой значения, равные единице.
9. Используйте команды who и whos для получения информации о всех использованных в лабораторной работе переменных.
10. Приведите из журнала выполнения лабораторной работы несколько первых и последних строк.
>> N = 5
N =
5
>> A = (cot(N))^-4
A =
130.5965
>> B = log(N + N^-3 + 9)
B =
2.6396
>> C = N/exp(-N)
C =
742.0658
>> D = C/(A + B)
D =
5.5696
>> k = A*D^1/5/(C+ B^4)
k =
0.1840
>> x = [0.2, 0.3, 0.5, 0.8, 1.3, 1.7, 2.5, N, k]
x =
Columns 1 through 7
0.2000 0.3000 0.5000 0.8000 1.3000 1.7000 2.5000
Columns 8 through 9
5.0000 0.1840
>> x = [0.2, 0.3, 0.5, 0.8, 1.3, 1.7, 2.5, 5, 0.1840]
x =
Columns 1 through 7
0.2000 0.3000 0.5000 0.8000 1.3000 1.7000 2.5000
Columns 8 through 9
5.0000 0.1840
>> x(1)
ans =
0.2000
>> A = [0,0,0,0,0,0,0,0,0]
A =
0 0 0 0 0 0 0 0 0
>> for i = 1:9
A(i) = sin(x(i))^2/(1 + cos(x(i))) + exp(-x(i))*log(x(i));
end
>> A
A =
Columns 1 through 7
-1.2978 -0.8473 -0.2980 0.2030 0.8040 1.2258 1.8764
Columns 8 through 9
0.7272 -1.3914
>> v = [x(1),x(2),x(3),x(4),x(5),x(6),x(7),x(8),x(9),A(5),A(6),A(7),A(8),A(9)]
v =
Columns 1 through 7
0.2000 0.3000 0.5000 0.8000 1.3000 1.7000 2.5000
Columns 8 through 14
5.0000 0.1840 0.8040 1.2258 1.8764 0.7272 -1.3914
>> v1 = [0,0,0,0,0,0,0,0,0,0,0,0,0,0]
v1 =
Columns 1 through 13
0 0 0 0 0 0 0 0 0 0 0 0 0
Column 14
0
>> for i = 1:14
v1(i) =v(i) + 2.1;
end
>> v1
v1 =
Columns 1 through 7
2.3000 2.4000 2.6000 2.9000 3.4000 3.8000 4.6000
Columns 8 through 14
7.1000 2.2840 2.9040 3.3258 3.9764 2.8272 0.7086
>> w = v + v1
w =
Columns 1 through 7
2.5000 2.7000 3.1000 3.7000 4.7000 5.5000 7.1000
Columns 8 through 14
12.1000 2.4680 3.7080 4.5516 5.8527 3.5544 -0.6829
>> w1 = v - v1
w1 =
Columns 1 through 7
-2.1000 -2.1000 -2.1000 -2.1000 -2.1000 -2.1000 -2.1000
Columns 8 through 14
-2.1000 -2.1000 -2.1000 -2.1000 -2.1000 -2.1000 -2.1000
>> w2 = v1 - v
w2 =
Columns 1 through 7
2.1000 2.1000 2.1000 2.1000 2.1000 2.1000 2.1000
Columns 8 through 14
2.1000 2.1000 2.1000 2.1000 2.1000 2.1000 2.1000
>> w3 = v ./ v1
w3 =
Columns 1 through 7
0.0870 0.1250 0.1923 0.2759 0.3824 0.4474 0.5435
Columns 8 through 14
0.7042 0.0806 0.2769 0.3686 0.4719 0.2572 -1.9637
>> w3 = v / v1
w3 =
0.4516
>> w4 = v1.*v
w4 =
Columns 1 through 7
0.4600 0.7200 1.3000 2.3200 4.4200 6.4600 11.5000
Columns 8 through 14
35.5000 0.4203 2.3348 4.0767 7.4611 2.0559 -0.9859
>> R = sort(abs(w))
R =
Columns 1 through 7
0.6829 2.4680 2.5000 2.7000 3.1000 3.5544 3.7000
Columns 8 through 14
3.7080 4.5516 4.7000 5.5000 5.8527 7.1000 12.1000
>> R = sort(w)
R =
Columns 1 through 7
-0.6829 2.4680 2.5000 2.7000 3.1000 3.5544 3.7000
Columns 8 through 14
3.7080 4.5516 4.7000 5.5000 5.8527 7.1000 12.1000
>> R = -sort(-w)
R =
Columns 1 through 7
12.1000 7.1000 5.8527 5.5000 4.7000 4.5516 3.7080
Columns 8 through 14
3.7000 3.5544 3.1000 2.7000 2.5000 2.4680 -0.6829
>> w5 = v1.^v
w5 =
1.0e+004 *
Columns 1 through 7
0.0001 0.0001 0.0002 0.0002 0.0005 0.0010 0.0045
Columns 8 through 14
1.8042 0.0001 0.0002 0.0004 0.0013 0.0002 0.0002
>> ww = zeros(1,12)
ww =
0 0 0 0 0 0 0 0 0 0 0 0
>> ww(1,1) = w(3)
ww =
Columns 1 through 7
3.1000 0 0 0 0 0 0
Columns 8 through 12
0 0 0 0 0
>> ww(1,2) = w(5)
ww =
Columns 1 through 7
3.1000 4.7000 0 0 0 0 0
Columns 8 through 12
0 0 0 0 0
>> ww(1,3) = w1(3)
ww =
Columns 1 through 7
3.1000 4.7000 -2.1000 0 0 0 0
Columns 8 through 12
0 0 0 0 0
>> ww(1,4) = w1(5)
ww =
Columns 1 through 7
3.1000 4.7000 -2.1000 -2.1000 0 0 0
Columns 8 through 12
0 0 0 0 0
>> ww(1,5) = w2(3)
ww =
Columns 1 through 7
3.1000 4.7000 -2.1000 -2.1000 2.1000 0 0
Columns 8 through 12
0 0 0 0 0
>> ww(1,6) = w2(5)
ww =
Columns 1 through 7
3.1000 4.7000 -2.1000 -2.1000 2.1000 2.1000 0
Columns 8 through 12
0 0 0 0 0
> w3 = v ./ v1
w3 =
Columns 1 through 7
0.0870 0.1250 0.1923 0.2759 0.3824 0.4474 0.5435
Columns 8 through 14
0.7042 0.0806 0.2769 0.3686 0.4719 0.2572 -1.9637
>> ww(1,7) = w3(3)
ww =
Columns 1 through 7
3.1000 4.7000 -2.1000 -2.1000 2.1000 2.1000 0.1923
Columns 8 through 12
0 0 0 0 0
>> ww(1,8) = w3(5)
ww =
Columns 1 through 7
3.1000 4.7000 -2.1000 -2.1000 2.1000 2.1000 0.1923
Columns 8 through 12
0.3824 0 0 0 0
>> ww(1,9) = w4(3)
ww =
Columns 1 through 7
3.1000 4.7000 -2.1000 -2.1000 2.1000 2.1000 0.1923
Columns 8 through 12
0.3824 1.3000 0 0 0
>> ww(1,10) = w4(5)
ww =
Columns 1 through 7
3.1000 4.7000 -2.1000 -2.1000 2.1000 2.1000 0.1923
Columns 8 through 12
0.3824 1.3000 4.4200 0 0
>> ww(1,11) = w5(3)
ww =
Columns 1 through 7
3.1000 4.7000 -2.1000 -2.1000 2.1000 2.1000 0.1923
Columns 8 through 12
0.3824 1.3000 4.4200 1.6125 0
>> ww(1,12) = w5(5)
ww =
Columns 1 through 7
3.1000 4.7000 -2.1000 -2.1000 2.1000 2.1000 0.1923
Columns 8 through 12
0.3824 1.3000 4.4200 1.6125 4.9082
>> max1 = max(ww)
max1 =
4.9082
>> min1 = min(ww)
min1 =
-2.1000
>> sum(ww)
ans =
20.6153
>> prouz = prod(ww)
prouz =
947.4858
>> for i = 3:6
ww(1,i) = 1;
end
>> ww
ww =
Columns 1 through 7
3.1000 4.7000 1.0000 1.0000 1.0000 1.0000 0.1923
Columns 8 through 12
0.3824 1.3000 4.4200 1.6125 4.9082
>> who ww
Your variables are:
ww
>> who x
Your variables are:
x
>> whos x
Name Size Bytes Class
x 1x9 72 double array
Grand total is 9 elements using 72 bytes
>> who ww
Your variables are:
ww
>> whos ww
Name Size Bytes Class
ww 1x12 96 double array
Grand total is 12 elements using 96 bytes
Variables created in current workspace.
Variables created in current workspace.