Конвертер валютUSD 2,9921EUR 3,3424Моя статистикаПройдите любой тест
Все записи блога →
Последние Новости
  • Тур Хейердал — путешественник, переплывший океан на плоту
    Шесть мужчин, бальсовый плот и бескрайний Тихий океан. Тур Хейердал хотел проверить смелую идею: могли ли жители Южной Америки в древности добраться до островов Полинезии. Чтобы узнать это, он сам отправился в путь.Путь к успехуТур Хейердал родился 6 октября 1914 года в городе Ларвик в Норвегии. С детства он увлекался зоологией и дикой природой. В 1937–1938 годах Тур с женой прожил около года на острове Фату-Хива в Полинезии. Именно там, наблюдая за ветрами и течениями, он задумался о происхожде...
  • Христофор Колумб — мореплаватель, открывший Европе Америку
    Утром 12 октября 1492 года матрос с корабля «Пинта» крикнул, что видит берег. Через несколько часов три небольших судна подошли к острову, который местные жители называли Гуанахани. Экспедиция Христофора Колумба завершила первый переход через Атлантический океан, после которого мир перестал быть прежним.Путь к экспедицииКолумб родился около 1451 года в Генуе в семье ткача. Он рано ушёл в море, плавал по Средиземному и Атлантическому океанам, жил в Португалии. Он был уверен, что до Индии и Китая ...
  • Фрэнк Синатра — «Голос» века, певший по-своему
    Шляпа с лентой, небрежно накинутый плащ, бархатный баритон — Фрэнк Синатра умел превратить трёхминутную песню в маленький спектакль. Прозвище «Голос» закрепилось за ним ещё в 1940-х, и за десятилетия его мало кто смог оспорить.Путь к успехуСинатра родился в декабре 1915 года в Хобокене, штат Нью-Джерси, в семье итальянских эмигрантов. Музыкального образования он почти не получил, зато с юности пел на радио и в клубах. Первые успехи пришли в оркестрах Гарри Джеймса и Томми Дорси. В начале 194...
  • Михаил Булгаков — мастер, которого прочли после смерти
    Автор, которого при жизни почти не печатали, оказался одним из самых читаемых писателей столетия. История Михаила Афанасьевича Булгакова — это история терпения, упорства и веры в свою книгу.Путь к успехуБулгаков родился в 1891 году в Киеве, в семье преподавателя духовной академии. В 1916 году он окончил медицинский факультет Киевского университета и сразу начал работать врачом, в том числе в земской больнице в селе Никольском Смоленской губернии. Эти годы позже отразились в «Записках юного врача...
  • Дмитрий Менделеев — химик, составивший карту всех элементов
    Дмитрий Иванович Менделеев родился 8 февраля 1834 года (27 января по старому стилю) в Тобольске, в большой семье директора гимназии. Рос он в трудное время, но мать, по семейным преданиям, сделала всё, чтобы младший сын получил образование. Так будущий учёный оказался в Петербурге.Путь к успехуОкончив Главный педагогический институт, Менделеев стажировался в Европе, а в 1860-х годах стал профессором Петербургского университета. Читая курс неорганической химии, он не нашёл подходящего учебника и ...
  • Роальд Амундсен — покоритель полюсов и северо-западного прохода
    Полярные льды веками хранили свои тайны. Роальд Амундсен разгадал сразу несколько из них. Он не искал лёгкой славы: каждый его поход был итогом долгой учёбы у местных народов и внимательного расчёта.Путь к успехуАмундсен родился 16 июля 1872 года недалеко от города Борге в Норвегии. Он собирался стать врачом, но, прочитав о полярных экспедициях, выбрал другую жизнь. В 1897–1899 годах он участвовал в бельгийской экспедиции на судне «Бельжика», которая стала первой, перезимовавшей в Антарктике. Та...
  • Франциск Скорина — первопечатник Беларуси и Восточной Европы
    В 1517 году в Праге вышла небольшая книга, которую можно держать в одной руке. Это была Псалтирь, а на её страницах стояло имя издателя: «Франциск Скорина из Полоцка, в лекарских науках доктор». Так началась история восточнославянского книгопечатания.Путь к книгеТочная дата рождения Скорины неизвестна, обычно называют около 1490 года. Он родился в Полоцке в семье купца. В 1504 году его имя записано среди студентов Краковского университета. В 1512 году в итальянской Падуе он получил степень докто...
  • Марк Шагал — художник, чьи герои парят над городом
    На картинах Марка Шагала люди летают над крышами, скрипач сидит на домике, а синяя корова смотрит на зрителя человеческими глазами. Это не просто фантазия: художник всю жизнь рисовал родной Витебск, каким его хранила память, — с поэтической логикой сна.Путь к успехуМарк Шагал (при рождении Мовша Шагал) родился в 1887 году в семье бедного еврейского рабочего недалеко от Витебска и вырос в самом Витебске. Он учился у местного художника Юделя Пэна, затем уехал в Санкт-Петербург. В 191...
  • Янка Купала — народный поэт Беларуси
    Когда в начале XX века молодой поэт из деревни под Минском подписал свои стихи псевдонимом «Янка Купала», он, возможно, и не думал, что станет голосом целого народа. Но именно так и произошло.Путь к успехуИван Доминикович Луцевич родился в 1882 году в фольварке Вязынка близ Молодечно. Семья была небогатой: родители арендовали землю. Учился он в народном училище, потом работал домашним учителем, писарем, помощником провизора, много читал и рано начал писать стихи. Первое стихотворение «Мужик» нап...
  • Луи Пастер — учёный, победивший невидимых врагов
    Луи Пастер родился 27 декабря 1822 года в городке Доль на востоке Франции, в семье кожевника. Он был прилежным, но не блестящим учеником и интересовался живописью. Однако судьбу решила химия: она повела его от кристаллов к микробам и спасению жизней.Путь к успехуПервое крупное открытие Пастер сделал в 1848 году, изучая кристаллы солей винной кислоты. Он заметил, что они бывают двух зеркально отражённых форм, и тем самым заложил основы стереохимии. Позже он занялся брожением и показал, что за нег...
МатематикаМоя статистика

Тест по MATLAB

100 вопросов в 10 темах (лёгкий — 35, средний — 40, сложный — 25). Выберите темы, уровень и количество вопросов — к каждому ответу есть объяснение.

Векторы и матрицы, индексация, поэлементные и матричные операции, функции и анонимные функции, линейная алгебра, графики, ode45 и численные методы, ячейки и структуры, векторизация. Вопросы на английском.

Все вопросы теста 100

Нажмите на вариант ответа, чтобы проверить себя, или «Показать ответ».

Basics and syntax10
1Лёгкий
What does the semicolon at the end of this statement do?
x = 5;
  1. It suppresses the display of the result; x is still assigned the value 5
  2. It is required to end every statement; leaving it out causes a syntax error
  3. It makes x a constant that cannot be reassigned later
  4. It turns the rest of the line into a comment
2Лёгкий
You type this expression in the Command Window without assigning it to anything. Where is the value 7 stored?
3 + 4
  1. In the automatic variable ans
  2. In a variable named result
  3. Nowhere; it is only printed and then discarded
  4. In the variable that was assigned most recently
3Средний
What happens when this code runs?
v = [10 20 30];
v(0)
  1. An error: array indices must be positive integers
  2. It returns 30, because index 0 wraps around to the last element
  3. It returns 10, the first element
  4. It returns [] (an empty array)
4Средний
What is the value of ans after these three lines run?
x = 7;
x + 1;
y = 2 * x;
  1. 14
  2. 7
  3. ans is undefined, because x + 1; was suppressed by the semicolon
  4. 8
5Сложный
What is the value of z after this code?
for i = 1:3
end
z = 2 + 3*i
  1. 2.0000 + 3.0000i
  2. 11
  3. An error, because the loop variable i no longer exists after the loop
  4. [5 8 11]
6Лёгкий
Which of these lines is a comment in MATLAB?
  1. % compute the mean
  2. // compute the mean
  3. /* compute the mean */
  4. -- compute the mean
7Лёгкий
Which command removes all variables from the workspace?
  1. clc
  2. close all
  3. clf
  4. clear
8Лёгкий
Which of these is a valid MATLAB variable name?
  1. velocity_2
  2. _velocity
  3. 2velocity
  4. velocity-2
9Средний
What is total after these two lines?
total = 1 + 2 ...
      + 3;
  1. 6
  2. 3, and the second line is evaluated separately as ans = 3
  3. An error, because a statement cannot start with +
  4. An error, because ... is not valid MATLAB syntax
10Сложный
What is a after this code?
a = 5;
a(3) = 1;
  1. An error, because index 3 exceeds the size of a scalar
  2. [5 1]
  3. 1, because a is overwritten
  4. [5 0 1]
Vectors and matrices10
11Лёгкий
What does the expression 1:2:9 produce?
  1. [1 2 3 4 5 6 7 8 9]
  2. [2 4 6 8]
  3. [1 3 5 7]
  4. [1 3 5 7 9]
12Лёгкий
What does size(zeros(3, 4)) return?
  1. [3 4]
  2. [4 3]
  3. 12
  4. 7
13Средний
What are the values of length(A) and numel(A)?
A = ones(2, 5);
  1. 2 and 10
  2. 5 and 10
  3. 10 and 10
  4. 5 and 7
14Средний
What does linspace(0, 1, 4) return?
  1. [0 0.2500 0.5000 0.7500 1.0000]
  2. [0 0.2500 0.5000 0.7500]
  3. [0 0.3333 0.6667]
  4. [0 0.3333 0.6667 1.0000]
15Сложный
What does size(B) return?
A = [1 2; 3 4];
B = cat(3, A, A);
  1. [4 2]
  2. [2 4]
  3. [2 2 2]
  4. [2 2 3]
16Лёгкий
What does eye(3) create?
  1. A 3x3 matrix of ones
  2. The 3x3 identity matrix: ones on the main diagonal, zeros elsewhere
  3. The row vector [1 1 1]
  4. A 3x3 matrix with ones on the anti-diagonal
17Лёгкий
What does zeros(3) create?
  1. A 3x3 matrix of zeros
  2. The column vector [0; 0; 0]
  3. The row vector [0 0 0]
  4. The scalar 0, repeated three times in the output
18Средний
What happens with this statement?
M = [1 2; 3 4 5];
  1. An error, because the rows have different numbers of columns
  2. M is the 1x5 row vector [1 2 3 4 5]
  3. M is [1 2 0; 3 4 5], with the short row padded by zero
  4. M becomes a cell array with rows of different lengths
19Средний
What does 5:1 return?
  1. [5 4 3 2 1]
  2. An empty 1x0 array
  3. An error, because the start is greater than the end
  4. 5
20Сложный
What does repmat([1 2], 2, 2) return?
  1. [1 2; 1 2]
  2. [1 1 2 2; 1 1 2 2]
  3. [2 4]
  4. [1 2 1 2; 1 2 1 2]
Indexing10
21Лёгкий
What does A(2, 3) return?
A = [1 2 3; 4 5 6];
  1. 6
  2. 3
  3. 5
  4. 4
22Лёгкий
What does v(v > 4) return?
v = [5 8 2 9];
  1. [1 1 0 1]
  2. [5 8 9]
  3. [1 2 4]
  4. 3
23Средний
What does A(3) return?
A = [1 2 3; 4 5 6];
  1. 3
  2. 4
  3. 2
  4. An error: a matrix needs two subscripts
24Средний
What is v after this code?
v = [5 8 2 9];
v(2) = [];
  1. [5 0 2 9]
  2. [5 2 9 0]
  3. An error, because [] cannot be assigned to one element
  4. [5 2 9]
25Сложный
What does sub2ind([3 4], 2, 3) return (the linear index of row 2, column 3 in a 3x4 matrix)?
  1. 7
  2. 8
  3. 6
  4. 10
26Лёгкий
What does v(end) return?
v = [4 7 1 9 3];
  1. 5, the length of v
  2. 3
  3. 9, the largest element
  4. An error: end can only close a block such as for or if
27Лёгкий
What does A(:, 2) return?
A = [1 2 3; 4 5 6];
  1. [4 5 6], the second row
  2. [2 5] as a row vector
  3. 4, the second element in memory
  4. [2; 5], the second column as a column vector
28Средний
What is v after this code?
v = 1:3;
v(6) = 1;
  1. An error: index exceeds the number of array elements
  2. [1 2 3 1]
  3. [1 2 3 0 0 1]
  4. [1 2 3 NaN NaN 1]
29Средний
What does A(end, end-1) return?
A = [1 2 3; 4 5 6; 7 8 9];
  1. 8
  2. 6
  3. 9
  4. 7
30Сложный
What happens with this code?
v = [10 20 30];
idx = [1 0 1];
w = v(idx);
  1. w is [10 30]
  2. w is [10 0 30]
  3. w is [10 10], the index 0 is skipped
  4. An error, because 0 is not a valid numeric index
Element-wise vs matrix operations10
31Лёгкий
What does this expression return?
[1 2 3] .* [4 5 6]
  1. [4 10 18]
  2. 32
  3. [5 7 9]
  4. An error: inner matrix dimensions must agree
32Средний
What happens when this expression is evaluated?
[1 2 3] * [4 5 6]
  1. It returns 32, the dot product
  2. It returns [4 10 18]
  3. It returns a 3x3 matrix
  4. An error, because the inner dimensions of a 1x3 and a 1x3 matrix do not agree
33Средний
What does A^2 return?
A = [1 2; 3 4];
  1. [1 4; 9 16]
  2. [7 10; 15 22]
  3. [2 4; 6 8]
  4. An error: use .^ for matrices
34Сложный
What does z' return?
z = [1+2i, 3];
  1. [1+2i; 3]
  2. [1-2i, 3] (still a row vector)
  3. [1-2i; 3]
  4. An error, because ' is not defined for complex numbers
35Сложный
In MATLAB R2016b or newer (and in GNU Octave), what does this expression return?
[1; 2] + [10 20 30]
  1. An error: matrix dimensions must agree
  2. [11 22]
  3. A 1x6 row vector
  4. [11 21 31; 12 22 32]
36Лёгкий
Why does the second line fail?
x = 0:0.5:2;
y = x^2;
  1. Because x must be a column vector
  2. Because ^ is the matrix power, which needs a square matrix; element-wise squaring is x.^2
  3. Because 0 cannot be raised to a power
  4. Because squaring is only allowed inside a for loop
37Лёгкий
What does size([1 2 3]') return?
  1. [1 3]
  2. 3
  3. [3 1]
  4. [3 3]
38Средний
What does this expression return?
[1 2 3] * [4 5 6]'
  1. [4 10 18]
  2. A 3x3 matrix
  3. An error: inner matrix dimensions must agree
  4. 32
39Средний
v = [1 2 4]. Which expression returns [2 1 0.5]?
  1. 2 ./ v
  2. 2 / v
  3. v / 2
  4. v .^ 2
40Сложный
b is a 1x3 row vector and A is a nonsingular 3x3 matrix. What does x = b / A compute?
  1. Each element of b divided by the corresponding element of A
  2. The column vector x that solves A*x = b
  3. An error, because / cannot divide by a matrix
  4. The row vector x that solves x*A = b
Control flow and functions10
41Лёгкий
What is s after this loop?
s = 0;
for k = 1:4
    s = s + k;
end
  1. 4
  2. 10
  3. 6
  4. 15
42Лёгкий
What does f(3) return?
f = @(x) x.^2 + 1;
  1. 10
  2. 7
  3. 16
  4. An error: anonymous functions must be called with feval
43Средний
Given this function file sumprod.m, what is r after r = sumprod(2, 3)?
function [s, p] = sumprod(a, b)
    s = a + b;
    p = a * b;
end
  1. 6
  2. [5 6]
  3. 5
  4. An error, because both outputs must be requested
44Средний
What is s after this loop?
s = 0;
for k = 1:10
    if mod(k, 2) == 0
        continue
    end
    s = s + k;
end
  1. 30
  2. 55
  3. 9
  4. 25
45Сложный
What does this code display?
x = [3 -1 2];
if x > 0
    disp('all positive')
else
    disp('not all positive')
end
  1. not all positive
  2. all positive
  3. An error, because if needs a scalar condition
  4. It prints a message once for each element of x
46Лёгкий
What is n after this loop?
n = 1;
while n < 50
    n = n * 2;
end
  1. 32
  2. 50
  3. 64
  4. 128
47Средний
Given this function file scale.m, what does scale(3) return?
function y = scale(x, k)
    if nargin < 2
        k = 10;
    end
    y = k * x;
end
  1. An error: not enough input arguments
  2. 30
  3. 3
  4. 0, because the missing k defaults to 0
48Средний
In MATLAB, the file area.m begins with the line below. How is this function called from the command line?
function r = circleArea(d)
  1. area(2)
  2. circleArea(2)
  3. Either area(2) or circleArea(2)
  4. It cannot be called; MATLAB refuses to load the file
49Сложный
What does f(3) return at the end of this code?
a = 2;
f = @(x) a * x;
a = 10;
f(3)
  1. 30
  2. 6
  3. An error, because a is not an input of f
  4. [6 30]
50Сложный
What is n after this loop?
n = 0;
for c = [1 2 3; 4 5 6]
    n = n + 1;
end
  1. 6
  2. 2
  3. 3
  4. 1
Linear algebra10
51Лёгкий
What is the recommended way to solve the linear system A*x = b for a square, nonsingular A and column vector b?
  1. x = b \ A
  2. x = A / b
  3. x = b / A
  4. x = A \ b
52Лёгкий
What does det([1 2; 3 4]) return?
  1. 2
  2. 10
  3. -2
  4. 24
53Средний
What does rank(A) return?
A = [1 2 3; 2 4 6; 1 0 1];
  1. 3
  2. 2
  3. 1
  4. 0
54Средний
What does MATLAB do when it runs this code?
A = [1 2; 2 4];
x = A \ [3; 6];
  1. It stops with an error, because a singular system has no unique solution
  2. It silently returns the minimum-norm solution
  3. It prints a warning that the matrix is singular to working precision and still returns a result that should not be trusted
  4. It returns an empty matrix []
55Сложный
cond(A) returns about 1e12 for a matrix A. What does that tell you about x = A \ b computed in double precision?
  1. A is singular, so A \ b will always fail
  2. The determinant of A is about 1e12
  3. Roughly 12 of the about 16 significant decimal digits of x may be lost to rounding errors
  4. Solving the system will take about 1e12 times longer than for a well-conditioned matrix
56Лёгкий
What does norm([3 4]) return?
  1. 7
  2. 25
  3. 5
  4. 4
57Средний
After [V, D] = eig(A) for a square matrix A, which statement is true?
  1. The rows of V are the eigenvectors and A*V = D*V
  2. The columns of V are eigenvectors, D is diagonal with the eigenvalues, and A*V = V*D
  3. V holds the eigenvalues and D the eigenvectors
  4. D is the determinant of A and V its inverse
58Средний
Why is x = A \ b preferred over x = inv(A) * b?
  1. Because inv only works for 2x2 matrices
  2. Because the results are identical and A \ b is just shorter to type
  3. Because A \ b solves the system with a factorization without forming the inverse, which needs fewer operations and usually gives smaller rounding errors
  4. Because inv(A) * b returns a row vector instead of a column vector
59Сложный
What does x = A \ b return for this non-square system?
A = [1 0; 1 1; 1 2];
b = [1; 2; 2];
x = A \ b;
  1. An error, because A must be square
  2. The exact solution of the first two equations only
  3. The 2x1 least-squares solution that minimizes norm(A*x - b)
  4. A 3x1 vector, one value per equation
60Сложный
What are norm(A, 1) and norm(A, Inf)?
A = [1 -2; 3 4];
  1. 6 and 7
  2. 7 and 6
  3. 4 and 7
  4. 10 and 10
Plotting10
61Лёгкий
What does hold on do?
  1. It keeps the current plot so the next plot command adds to the same axes instead of replacing it
  2. It pauses the script until the figure window is closed
  3. It locks the axis limits but still replaces the existing lines
  4. It opens a new figure window for every following plot command
62Лёгкий
What does this command draw?
plot(x, y, 'r--o')
  1. A red solid line with the letter o printed at each point
  2. A red dotted line with zero markers
  3. A red dashed line with circle markers at the data points
  4. A red line twice as thick as the default
63Средний
In a figure divided with subplot(2, 3, p), where is the axes created by subplot(2, 3, 4)?
  1. Row 1, column 2
  2. Row 2, column 2
  3. Nowhere: it is an error, because 4 is larger than the 3 columns
  4. Row 2, column 1
64Средний
What is size(X) after this call?
[X, Y] = meshgrid(1:3, 1:2);
  1. [3 2]
  2. [2 3]
  3. [1 3]
  4. [6 1]
65Сложный
A is a 3x4 matrix. What does plot(A) draw?
  1. Three lines, one for each row
  2. Four lines, one for each column, each plotted against the indices 1, 2, 3
  3. A single line through all 12 values in column-major order
  4. A 3-D surface, since A is a matrix
66Лёгкий
Which command labels the horizontal axis of the current plot?
  1. title('Time (s)')
  2. xlabel('Time (s)')
  3. legend('Time (s)')
  4. xlim('Time (s)')
67Лёгкий
What is the main visual difference between mesh(X, Y, Z) and surf(X, Y, Z)?
  1. mesh needs meshgrid matrices and surf accepts only vectors
  2. surf draws a 2-D contour plot and mesh a 3-D surface
  3. There is no difference; they are aliases
  4. mesh draws only the colored grid lines (a wireframe), while surf also fills the faces with color
68Средний
What are the x coordinates of the points drawn by this code?
y = [4 1 3];
plot(y)
  1. 0, 1, 2
  2. 4, 1, 3 (the values are plotted against themselves)
  3. 1, 2, 3
  4. Nothing is drawn: plot needs both x and y
69Средний
You plot a circle with plot(cos(t), sin(t)) and it looks like an ellipse. What does axis equal change?
  1. It uses the same length for one data unit on the x and y axes, so the circle looks round
  2. It sets the same numeric limits for both axes, e.g. [-1 1] for x and y
  3. It resizes the figure window to a square
  4. It forces both axes to start at 0
70Сложный
Why does the last line fail?
x = 0:0.1:1;
y = 0:0.1:2;
[X, Y] = meshgrid(x, y);
Z = X * Y;
surf(X, Y, Z)
  1. meshgrid must be called as meshgrid(y, x)
  2. surf accepts only vectors, not matrices
  3. Z must be computed in a nested for loop
  4. X * Y is a matrix product of two 21x11 matrices, whose inner dimensions do not agree; Z = X .* Y is needed
Numerical methods10
71Лёгкий
What does fzero return here?
r = fzero(@(x) cos(x) - x, 1);
  1. 1, the starting point
  2. 0.5403, which is cos(1)
  3. About 0.7391, a point where cos(x) = x
  4. 0, because fzero looks for the minimum of the function
72Лёгкий
What is p after this call?
p = polyfit([0 1 2], [1 3 5], 1);
  1. [2 1] (approximately): slope 2, intercept 1
  2. [1 2]: intercept 1, slope 2
  3. [1 3 5]
  4. 2, only the slope
73Средний
You want to solve dy/dt = t - y with ode45. Which function handle has the correct form?
  1. @(y, t) t - y
  2. @(t) t - y
  3. @(t, y) t - y
  4. 't - y'
74Средний
Why does this call fail, and what fixes it?
q = integral(@(x) x^2, 0, 3);
  1. integral needs an expression string: integral('x^2', 0, 3)
  2. The limits must be passed as one vector: integral(@(x) x^2, [0 3])
  3. integral only accepts named functions, not anonymous ones
  4. integral calls the function with a vector of x values, so x^2 is an invalid matrix power; write x.^2 (the result is 9)
75Сложный
What happens with this call?
r = fzero(@(x) x.^2 - 1, [-2 2]);
  1. It returns -1, the first root in the interval
  2. It stops with an error, because the function has the same sign at both ends of the interval
  3. It returns 1, the positive root
  4. It returns 0, the midpoint where the function is smallest
76Лёгкий
What does polyval([2 0 -1], 3) return?
  1. 17
  2. -7
  3. 5
  4. 1
77Средний
After this call, which statement about t and y is true?
[t, y] = ode45(@(t, y) -2*y, [0 1], 1);
  1. t is [0; 1] and y holds the solution only at these two times
  2. t is a column vector of time points chosen by the solver and y has one row per element of t; y(end) approximates exp(-2)
  3. y is a function handle that can be evaluated at any time
  4. t and y are row vectors of exactly 100 equally spaced points
78Средний
What do trapz(y) and trapz(x, y) return?
x = 0:0.5:2;
y = x.^2;
  1. 2.75 and 2.75
  2. 2.75 and 5.5
  3. 2.6667 and 2.6667
  4. 5.5 and 2.75
79Средний
What does this call return?
v = interp1([1 2 3], [10 20 30], 4);
  1. 40, extrapolated linearly
  2. 30, the value at the nearest end point
  3. NaN
  4. An error, because 4 is outside the data
80Сложный
The equation y'' = -y is written as a first-order system with state [y; y']. Which expression gives the position y(t) at all returned time points?
f = @(t, u) [u(2); -u(1)];
[t, U] = ode45(f, [0 pi], [0; 1]);
  1. U(1, :)
  2. U(:, 2)
  3. U(:, 1)
  4. U(end)
Strings and cell arrays10
81Лёгкий
What does s contain?
s = ['Hello', ' ', 'world'];
  1. 'Hello world', a 1x11 char vector
  2. A 1x3 cell array of words
  3. 'Helloworld', because the blank is dropped
  4. An error: use strcat to join text
82Средний
What are class(a) and class(b)?
c = {42, 'text', [1 2 3]};
a = c(2);
b = c{2};
  1. 'char' and 'char'
  2. 'char' and 'cell'
  3. 'cell' and 'char'
  4. 'cell' and 'cell'
83Средний
What is x?
x = double('42');
  1. 42
  2. '42'
  3. An error: a string cannot be converted with double
  4. [52 50]
84Средний
What happens with this statement?
names = ['Ann'; 'Bob'; 'Kate'];
  1. A 3x4 char matrix, with 'Ann' and 'Bob' padded with a blank
  2. An error, because the rows of a char matrix must all have the same length
  3. A 1x10 char vector 'AnnBobKate'
  4. A 3x1 cell array of names
85Сложный
What does this expression return?
'ab' + 'cd'
  1. 'abcd'
  2. An error, because + is not defined for text
  3. [196 198]
  4. 394
86Лёгкий
How do you read the age field of this structure?
s.name = 'Ann';
s.age = 31;
  1. s{'age'}
  2. s.age
  3. s('age')
  4. s->age
87Лёгкий
a = 'cat' and b = 'cats'. Which expression safely tests whether the two char vectors are equal?
  1. a == b
  2. all(a == b)
  3. strcmp(a, b)
  4. a = b
88Средний
What does c{3}(2) return?
c = {42, 'text', [1 2 3]};
  1. An error: a cell array cannot be indexed twice
  2. 'e'
  3. {2}
  4. 2
89Сложный
What does size(s) return?
s = struct('x', {1, 2, 3});
  1. [1 1], and s.x is the cell array {1, 2, 3}
  2. [1 3]: a struct array whose elements have x = 1, 2 and 3
  3. [1 1], and s.x is the vector [1 2 3]
  4. An error, because a value must not be a cell array
90Сложный
What is s(2).age after this code?
s(1).name = 'Ann';
s(1).age = 31;
s(2).name = 'Bob';
  1. 31, copied from s(1)
  2. [] (an empty array)
  3. An error: s(2) has no field age
  4. 0
Performance and pitfalls10
91Лёгкий
What does this comparison return?
0.1 + 0.2 == 0.3
  1. 0 (logical false)
  2. 1 (logical true)
  3. 0.3000
  4. An error, because == cannot compare floating-point numbers
92Лёгкий
Why is it recommended to write x = zeros(1, n) before a loop that fills x(k) for k = 1:n?
  1. Because assigning x(k) to a variable that does not exist yet is an error
  2. Because zeros makes x an integer array, which is faster
  3. Because otherwise x grows by one element per iteration, and MATLAB may have to reallocate and copy the whole array each time
  4. Because preallocation makes the loop run on several CPU cores
93Средний
What does this expression return?
int8(100) + int8(100)
  1. 200
  2. -56, because the value wraps around
  3. 127
  4. An error: integer overflow
94Средний
What does eps (called with no arguments) represent in double precision?
  1. The smallest positive number that can be stored, about 2.2251e-308
  2. The distance from 1.0 to the next larger double, about 2.2204e-16
  3. Exactly 1e-16, the error of every arithmetic operation
  4. The tolerance that == uses when it compares doubles
95Сложный
What does this expression return?
int32(7) / int32(2)
  1. 3, because integer division truncates
  2. 3.5000, of class double
  3. An error: use idivide for integers
  4. 4, of class int32
96Лёгкий
a and b are results of floating-point computations that should be mathematically equal. Which test is appropriate?
  1. a == b
  2. isequal(a, b)
  3. round(a) == round(b)
  4. abs(a - b) < tol, with a small tolerance tol suited to the magnitude of the values
97Средний
Which statement is the vectorized equivalent of this loop for a row vector x?
for k = 1:numel(x)
    y(k) = x(k)^2;
end
  1. y = x^2;
  2. y = x * x;
  3. y = sum(x.^2);
  4. y = x.^2;
98Средний
What does this expression return?
uint8(5) - uint8(10)
  1. -5
  2. 251, because the value wraps around
  3. 0
  4. An error, because the result is negative
99Сложный
What does this expression return?
int8(10) * 0.26
  1. 2.6000, of class double
  2. 2, of class int8
  3. 3, of class int8
  4. An error: integers can only be combined with integers of the same class
100Сложный
What does the second line return?
x = 2^53;
x + 1 == x
  1. 0 (false), since adding 1 always changes a number
  2. 1 (true)
  3. An error: integer overflow
  4. NaN

Как проходить тест

  • Выберите темы и уровень — лёгкий уровень проверяет определения и задачи в одно действие, средний — стандартные вычисления, сложный — многошаговые задачи и теорию.
  • Отвечайте касанием или с клавиатуры: 1–4 или A–D, Enter — следующий вопрос.
  • Читайте объяснения — после ошибки разбор открывается сразу, после верного ответа его можно раскрыть кнопкой «Почему».
  • Работайте над ошибками — «Повторить ошибки» в конце теста или режим «Только мои ошибки» потом: ответы запоминаются в этом браузере.

Незавершённый тест сохраняется — после перезагрузки страницы можно продолжить с того же вопроса.

Темы теста

  • Basics and syntax 10
  • Vectors and matrices 10
  • Indexing 10
  • Element-wise vs matrix operations 10
  • Control flow and functions 10
  • Linear algebra 10
  • Plotting 10
  • Numerical methods 10
  • Strings and cell arrays 10
  • Performance and pitfalls 10