Introduction to Linear Algebra using MATLAB

버전 1.0.0 (147 KB) 작성자: Pratik
Linear Algebra is a fundamental branch of mathematics that deals with vectors, matrices, and linear transformations, forming the backbone of
다운로드 수: 0
업데이트 날짜: 2025/11/8

라이선스 보기

%% Introduction to Linear Algebra using MATLAB
% Example: Solve the system of linear equations
% 2x + 3y = 8
% x - y = 1
clc; % Clear the Command Window
clear; % Clear all variables
close all; % Close all figures
% Step 1: Define coefficient matrix A
A = [2 3;
1 -1];
% Step 2: Define constant matrix b
b = [8;
1];
% Step 3: Solve for x using matrix division (A\b)
x = A\b;
% Step 4: Display the result
disp('Solution of the system A*x = b is:');
Solution of the system A*x = b is:
fprintf('x = %.2f\n', x(1));
x = 2.20
fprintf('y = %.2f\n\n', x(2));
y = 1.20
% Step 5: Verify the solution
check = A*x;
disp('Verification (A*x):');
Verification (A*x):
disp(check);
8.0000
1.0000
disp('It should be equal to vector b:');
It should be equal to vector b:
disp(b);
1
8
1
% Step 6: Optional - visualize the two equations
x_vals = -5:0.1:5; % Range for plotting
% Equation 1: 2x + 3y = 8 => y = (8 - 2x)/3
y1 = (8 - 2*x_vals)/3;
% Equation 2: x - y = 1 => y = x - 1
y2 = x_vals - 1;
figure;
plot(x_vals, y1, 'r', 'LineWidth', 2); hold on;
plot(x_vals, y2, 'b', 'LineWidth', 2);
grid on;
xlabel('x'); ylabel('y');
title('Graphical Solution of Linear Equations');
legend('2x + 3y = 8', 'x - y = 1', 'Location', 'best');
text(x(1), x(2), sprintf(' Solution (%.2f, %.2f)', x(1), x(2)), 'FontSize',
10, 'Color', 'k');

인용 양식

Pratik (2025). Introduction to Linear Algebra using MATLAB (https://kr.mathworks.com/matlabcentral/fileexchange/182526-introduction-to-linear-algebra-using-matlab), MATLAB Central File Exchange. 검색 날짜: .

MATLAB 릴리스 호환 정보
개발 환경: R2025b
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
태그 태그 추가

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
버전 게시됨 릴리스 정보
1.0.0