0% found this document useful (0 votes)
37 views1 page

Matlab - Symbolic Math

This document discusses various symbolic math operations in MATLAB like solving equations, derivatives, integrals, limits, substitutions, factoring, expanding, simplifying, matrix operations, series, solving differential equations, plotting, and Laplace transforms. It provides examples of using syms and symbolic functions to perform these operations.

Uploaded by

mansour
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views1 page

Matlab - Symbolic Math

This document discusses various symbolic math operations in MATLAB like solving equations, derivatives, integrals, limits, substitutions, factoring, expanding, simplifying, matrix operations, series, solving differential equations, plotting, and Laplace transforms. It provides examples of using syms and symbolic functions to perform these operations.

Uploaded by

mansour
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Session 7: Symbolic Calculations

An = solve(x^2 - 5*x + 3)
%% Symbolic Math Analytical solutions eval(An)
%% How to define -------------
syms x %% Solve---------------------
y = x^2 + x; syms x a b c
An = solve( a*x^2 + b*x + c)
%% diff, int -----------------
yd = diff(y)
yi = int(y)
%% Solve (Multi Variable)----
syms x y z
syms x y z
z = sin(x) + 2*x*y^2; F = x^2 + x*y + z*sin(x) +y; % F(x,y,z)=0

zd_y = diff(z, y) Fy = solve(F, y)


zi_y = int(z,y, 1,2) % Integral intervals Fz = solve(F, z)
Fx = solve(F, x)
%% limit ---------------------
z = sin(x)/x - y*x/(1-exp(x)); % 0/0 -0/0
%% Solve: System of Equations---
z_0 = limit(z, x, 0) syms x y
%% Subs ----------------------- An = solve(2*x + 3*y - 1, 4*x^2 - 2*y +3)
z = y*log(x) + tan(x*y^2);
z1 = subs(z, x, 3) AnX = eval(An.x)
z2 = subs(z, {x, y}, {5,2})
%% dsolve: diff Equations------
syms a b syms y(x) % define symbolic function
z3 = subs(z, {x, y}, {a, b})
% D2y + 2*Dy + y = 1, | y(0) = 2
%% Factor, Expand ------------
A = (1+x)^3*(x+y^5); DA1 = dsolve(diff(y,2)+2*diff(y,1)+y == 1,
Ax = expand(A) y(0)==2)
Af = factor(A)
DA1c = subs(DA1, 'C3', 1)
%% Pretty, Simplify-----------
S = (x^4 - 1 + x*(x^2 - 1))/(x^3 -1) %% dsolve: diff Equations-----
pretty(S) % D2y + 2*Dy + y =1 | y(0) = 2, Dy(0) = 3
Ss = simplify(S)
Dy = diff(y,1); DDy = diff(y,2);
%% Matrix Operations---------- DA2 = dsolve(DDy+2*Dy+y==1, y(0)==2, Dy(0)==3)
syms a b c d
A = [a, b; c d];
%% Plot: ezplot---------------
det(A) % Determinant of Matrix syms x
inv(A) % Inverse of Matrix y = x*sin(1/x);
eig(A) % Eigen Values ezplot(y, [-0.5 0.5])

%% Series----------------------- %% Plot: ezmesh, ezsurf-------


% 1/1^2 + 1/2^2 + 1/3^2 + ... = pi^2/6 syms x y

syms n z = sin(x+y) / (x^2 + y^2+1)^0.5;


symsum(1/n^2,1, inf) figure; ezmesh(z)
figure; ezsurf(z)
%% Series! ------------------
% 1 + x^2 + x^3 + x^4... = ? %% Laplas---------------------
clc, clear
syms x n
S = symsum(x^n, n,0,inf) syms x
L = laplace(sin(x))
%% Solve ------------------- Li = ilaplace(L)
% y = x^2 - 5*x + 3 (y == 0)
syms x % ztrans, fourier-------------

MATLAB Course By: Mansour Torabi

You might also like