Difference between revisions of "Упражнение 1. Matlab"

From Ilianko
m (Protected "Упражнение 1. Matlab" ([edit=sysop] (indefinite) [move=sysop] (indefinite)))
 
(4 intermediate revisions by the same user not shown)
Line 21: Line 21:
 
  A*x
 
  A*x
  
== Точност визаилизация ==
+
== Точност визуализация ==
format long
+
 
ans
+
>>format long
 +
>> 1/3
 +
ans =
 +
  0.333333333333333
 +
>> format short
 +
>> 1/3
 +
ans =
 +
  0.3333
  
 
== Въвеждане на символни променливи ==
 
== Въвеждане на символни променливи ==
  
 
<pre>
 
<pre>
syms a b x
+
>>syms a b x
(a+b)^20
+
>>(a+b)^20
expand(ans)
+
>>expand(ans)
 +
  ans =
 +
  a^20 + 20*a^19*b + 190*a^18*b^2 + 1140*a^17*b^3 + 4845*a^16*b^4 + 15504*a^15*b^5 + 38760*a^14*b^6 +
 +
77520*a^13*b^7 + 125970*a^12*b^8 + 167960*a^11*b^9 + 184756*a^10*b^10 + 167960*a^9*b^11 +
 +
125970*a^8*b^12 + 77520*a^7*b^13 + 38760*a^6*b^14 + 15504*a^5*b^15 + 4845*a^4*b^16 +
 +
1140*a^3*b^17 +  190*a^2*b^18 + 20*a*b^19 + b^20
 +
 
factor (ans)
 
factor (ans)
 
int(sin(x),x,a,b)
 
int(sin(x),x,a,b)

Latest revision as of 14:58, 19 April 2011

Записване на коментар

% comment

Въвеждане на матрица

A = [ 2 5 3; 5 8 2; 6 2 8]

Въвеждане на вектор

b = [1 2 3]

Транспонирана матрица

b = [1 2 3]
b =b' <=> b = [1; 2; 3]

Решаване система линейни уравнения

A = [ 2 5 3; 5 8 2; 6 2 8];
b = [1 2 3]';
%А.x=b
x = A\b
A*x

Точност визуализация

>>format long
>> 1/3
ans =
  0.333333333333333
>> format short
>> 1/3
ans =
  0.3333

Въвеждане на символни променливи

>>syms a b x
>>(a+b)^20
>>expand(ans)
  ans =
  a^20 + 20*a^19*b + 190*a^18*b^2 + 1140*a^17*b^3 + 4845*a^16*b^4 + 15504*a^15*b^5 + 38760*a^14*b^6 + 
77520*a^13*b^7 + 125970*a^12*b^8 + 167960*a^11*b^9 + 184756*a^10*b^10 + 167960*a^9*b^11 +
 125970*a^8*b^12 + 77520*a^7*b^13 + 38760*a^6*b^14 + 15504*a^5*b^15 + 4845*a^4*b^16 + 
1140*a^3*b^17 +  190*a^2*b^18 + 20*a*b^19 + b^20
 
factor (ans)
int(sin(x),x,a,b)
F= int(1/(x^24-1))
diff(F,x)
simplify(ans)
f=simple(ans)

echo on
ml_lec1.1
echo o
echo off
clc
A
clear
A
V = [2 3.14 -2.71 1.e-12]
x = 2.56
%sin, cos, tan, cot, sinh, ..., asin, ..., log, log10, exp, sqrt, abs, real, imag
z = 3 + 4i
format short
z
z2 = 4.5 - 6.7*i
z + z2
z2^2
1/Z2
sqrt(z2)
ab
abs(z)
z2\1
1/z2
% pi, i èëè g, Inf, NaN
mod(7,2)
div(7,2)
dv(7,2)
dev(7,2)
z = complex(a,b)
a = 3.5; b = 4.56;
z = complex(a,b)
% Operacii nad vektori, matrici i polinomi
X = 0:pi/200:2*pi;
zeros(5,4)
Z = zeros(5,4);
Z(3,2) = 1
Z(3,3) = 2
ones(5,4)
O = ones(5,4)
I = eye(7)
R = rand(5,4)
R = randn(5,4)
help randn
V = [1 2 3 4 5]
length(v)
length(V)
size(R)
R(3,4)=pi;
r
R
tril(R)
triu(R)
V = [1, 2, 3, 4, 5];
V = diag(V)
diag(V)
R(3,:)
R(:,2)
R(:,:)
R(3,:)=[]
R(:,3)=[]
% .*, ./, .\, .^
A = [1 2 3; 4 5 6; 7 8 9];
sin(A)
sqrt(A)
B = [3 2 1; 6 5 4; 9 8 7];
A .* B
A * B
A ./ B
A / B
A \ B
sin(A) .^2 + cos(A) .^2
cosh(A) .^2 - si
cosh(A) .^2 - sinh(A) .^2
rand(A)
% Obrabotka na eksperimentalni danni
V = [3 2 7 9 5 1 7 4]
max(V)
min(V)
mean(V)
sort(V)
sum(V)
prod(V)
diff(V)
x = 0:pi/100:pi;
y = sin(x);
trapz(x, y)
x = 0:pi/1000:pi;
trapz(x, y)
y = sin(x);
trapz(x, y)
A = magic(5)
sum(A)
sum (A,2)
sum (daig(A))
sum(diag(A))
sum(diag(rot90(A)))
min(A)
%Operacii s polinomi
p = [5 3 7 1 4 2]
p1 = p;
p2 = [3 6 2 4 1 7]
p = conv(p1,p2)
r = [1 2 3 4 5 6 7];
p = poly(r)
x = 0.9:0.01:7.1;
plot(x, polyval(p, x)), grid on
xlabel('x'), ylabel('y'), title('Polynom')
x = 0:pi/200:2*pi;
plot(x, sin(x), x, cos(x),'LineWidth', 2), grid on
legend('sin(x)', 'cos(x)')