107 lines
1.2 KiB
Matlab
107 lines
1.2 KiB
Matlab
A = [1,2;3,4]
|
|
det(A)
|
|
inv(A)*A
|
|
A*A
|
|
A.*A
|
|
A^2
|
|
A.^2
|
|
|
|
v=1:10
|
|
V=1:-0.1:0
|
|
|
|
v.^2
|
|
|
|
transpose(v) # or v'
|
|
|
|
A(1,:)
|
|
|
|
A(:,2)
|
|
|
|
|
|
#L1_NC.pdf
|
|
|
|
#1.a
|
|
x=-4:0.1:7.2;
|
|
p = x.^5-5*x.^4-16*x.^3+16*x.^2-17.*x+21;
|
|
|
|
#plot(x,p)
|
|
|
|
#1.b
|
|
x=-2.5;
|
|
p = [1,-5,-16,+16,-17,21];
|
|
polyval(p,x)
|
|
#1.c
|
|
roots(p)
|
|
|
|
polyval(p,7)
|
|
|
|
#2
|
|
x = 0:0.1*pi:2*pi;
|
|
|
|
f = sin(x);
|
|
g = sin(2*x);
|
|
h = sin(3*x);
|
|
|
|
|
|
#subplot(3,1,1)
|
|
#plot(x,f)
|
|
#subplot(3,1,2)
|
|
|
|
#plot(x,g)
|
|
#subplot(3,1,3)
|
|
|
|
#plot(x,h)
|
|
clf #clear plot
|
|
t= 0:0.1*pi:10*pi
|
|
|
|
R=3.8;
|
|
r=1;
|
|
|
|
x = (R+r)*cos(t) - r*cos((R/r+1)*t);
|
|
y = (R+r)*sin(t) - r*sin((R/r+1)*t);
|
|
|
|
plot(x,y)
|
|
|
|
[x, y] = meshgrid(-2:0.1:2, 0.5:0.1:4.5);
|
|
|
|
f = sin(e.^x).*cos(log(y));
|
|
clf
|
|
#mesh(x, y, f);
|
|
|
|
|
|
#xlabel('X-axis');
|
|
#ylabel('Y-axis');
|
|
#zlabel('Z-axis');
|
|
#title('3D Surface Plot using mesh');
|
|
#colormap('jet');
|
|
#colorbar;
|
|
#grid on;
|
|
|
|
|
|
figure;
|
|
plot3(x, y, f);
|
|
xlabel('X-axis');
|
|
ylabel('Y-axis');
|
|
zlabel('Z-axis');
|
|
title('3D Line Plot using plot3');
|
|
grid on;
|
|
|
|
|
|
|
|
function result = funct(n)
|
|
if n == 0
|
|
result = 1+1;
|
|
else
|
|
result = 1 + 1/ funct(n - 1);
|
|
end
|
|
end
|
|
% Increase the recursion limit to 5000
|
|
#max_recursion_depth(2025);
|
|
|
|
funct(2)
|
|
funct(10)
|
|
funct(100)
|
|
funct(2025)
|
|
|
|
|