0
0
MATLABdata~10 mins

Solving linear systems (A\b) in MATLAB - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to solve the system Ax = b.

MATLAB
x = A [1] b;
Drag options to blanks, or click blank then click option'
A\
B/
C*
D+
Attempts:
3 left
💡 Hint
Common Mistakes
Using * instead of \ to solve the system.
Using / which is for right division, not solving Ax = b.
2fill in blank
medium

Complete the code to solve the system and store the result in variable x.

MATLAB
x = [1] \ b;
Drag options to blanks, or click blank then click option'
Ainv(A)
Bb
Cx
DA
Attempts:
3 left
💡 Hint
Common Mistakes
Putting b before the backslash operator.
Using inv(A) which is less efficient and not recommended.
3fill in blank
hard

Fix the error in the code to correctly solve the system Ax = b.

MATLAB
x = A [1] b;
Drag options to blanks, or click blank then click option'
A/
B*
C\
D+
Attempts:
3 left
💡 Hint
Common Mistakes
Using / which performs right division, not solving the system.
Using * which multiplies matrices but does not solve equations.
4fill in blank
hard

Complete the code to create a matrix of solutions for multiple right-hand sides.

MATLAB
solutions = A [1] b(:, :);
Drag options to blanks, or click blank then click option'
A\
B:
C,
D*
Attempts:
3 left
💡 Hint
Common Mistakes
Using * instead of \ to solve the system.
Using , instead of : to select all rows.
5fill in blank
hard

Fill all three blanks to solve and store solutions for each column of b in an array.

MATLAB
for [1] = 1:size(b, 2)
    solutions([2]) = A [3] b(:, i);
end
Drag options to blanks, or click blank then click option'
Ai
C\
D*
Attempts:
3 left
💡 Hint
Common Mistakes
Using * instead of \ to solve the system.
Using a different variable name than the loop index.