커뮤니티
커리어
생활
족보실
4주차 과제

5주차 과제

4주차 해답
%% 1.
clc
a =''
for n = 1:20
f = fibonacci(n);
a = [a ' ' num2str(f)];
end
disp(a)
%% 2.
clc
x = linspace(-1,1,20);
y = linspace(-1,1,20);
[X Y] = meshgrid(x,y);
z = X.^3 - Y.^3
surf(z)
%% 3-1.
clc
x = -0.5:0.5:1;
y = [-7 3.2 4.5 2];
p = polyfit(x,y,3)
% p(x) = (6.8)x^3-(17.8)x^2+(9.8)x+(3.2)
%% 3-2.
clc
x = 5:8;
y = polyval(p,x)
5주차 해답
%% 1. Define the following functions and find the values and limits.
clc
close all
syms x
%(a)
f(x) = cos(x)
f(pi)
limit(f(x), 'x', -pi)
%(b)
g(x) = abs(x-1)-x
g(1)
limit(g(x),'x',0)
%(c)
h(x) = 2*exp(x)+1
h(g(1))
limit((h(x)-1)/x,'x',0,'left')
limit((h(x)-1)/x,'x',0,'right')
limit((h(x)-1)/x,'x',0)
%% 2. Plot the following functions with proper x-axis labels, y-axis labels and a grid.(a)
clc
close all
clear
syms x
f1(x) = sin(x);
fplot(f1(x), [-pi,pi])
xlabel('x');
ylabel('f1(x) = sin(x)');
grid;
%% (b)
clc
close all
clear
syms x
f2(x) = 2*x^2+2*x-1;
fplot(f2(x), [-2,1])
xlabel('x');
ylabel('f2(x) = 2*x^2+2*x-1');
grid;
%% (c)
clc
close all
clear
syms x
f3(x) = (exp(x)+exp(-x))/2;
fplot(f3(x), [-1,2])
xlabel('x');
ylabel('f3(x) = (exp(x)+exp(-x))/2');
grid;
%% 3. Find a minimum integer n satisfying abs(a(n) + 1) < 0.01
clc
close all
clear
syms n;
a(n) = -1+(-1)^n/n;
n = 1;
while abs(a(n)+1)>=0.01
n = n+1;
end
disp(n)
댓글 0개
조회 1041
