Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/angeloyeo/gongdols
Browse files Browse the repository at this point in the history
  • Loading branch information
angeloyeo committed May 23, 2021
2 parents 02d8cb3 + 7e26bed commit 5bce31f
Show file tree
Hide file tree
Showing 37 changed files with 973 additions and 98 deletions.
14 changes: 14 additions & 0 deletions MATLAB강의/debugging/case1_no_additional_functions/main.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
clear; close all; clc;

disp('Hello there!');

a = 1;
b = 2;

c = a * b + 3;

for i = 1:5
disp(['Hi. The iteration number is: ',num2str(i)]);
end

disp(c)
20 changes: 20 additions & 0 deletions MATLAB강의/debugging/case2_with_function_inside/main.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
clear; close all; clc;

disp('Hello there!');

a = 1;
b = 2;

cc = my_addition(a, b);


for i = 1:5
disp(['Hi. The iteration number is: ',num2str(i)]);
end

disp(cc)

function c = my_addition(a, b)

c = a + b;
end
24 changes: 24 additions & 0 deletions MATLAB강의/debugging/case3_with_functions_outside/main.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
clear; close all; clc;

disp('Hello there!');

a = 1;
b = 2;

cc = my_addition(a, b);

for i = 1:5
disp(['Hi. The iteration number is: ',num2str(i)]);
end

ii=1;
while(1)
disp('aaaa');
if ii == 5
break;
end
ii=ii+1;
end

disp(cc)

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
function c = my_addition(a, b)

c = a + b;
end
Binary file added 고려대학교zoom강의/210524lecture/fig1.mp4
Binary file not shown.
Binary file added 고려대학교zoom강의/210524lecture/fig2.mp4
Binary file not shown.
Binary file added 고려대학교zoom강의/210524lecture/fig3.mp4
Binary file not shown.
36 changes: 36 additions & 0 deletions 고려대학교zoom강의/210524lecture/fun_plotComplexPlane.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
function fun_plotComplexPlane(x1,x2,y1,y2,h_newfig)

if h_newfig
figure;
set(gcf,'position',[500,100,1000,650])
set(gcf,'color','w');
end
set(gca,'visible','off')
mArrow2(x1,0,x2,0,{'color','k'});
mArrow2(0,y1,0,y2,{'color','k'});
xlim([x1 x2])
ylim([y1 y2])

for i = (x1+1):(x2-1)
line([i i],[-0.05 0.05],'color','k')
line([-0.05 0.05],[i i],'color','k')
if i<=0
t= text(i-0.2, -0.3,num2str(i));
else
t= text(i-0.05, -0.3,num2str(i));
end
t.FontSize=15;

if i<0
t = text(-0.4, i,num2str(i));
elseif i>0
t = text(-0.3, i,num2str(i));
end
t.FontSize = 15;
end

t = text(x2*0.9,0.3,'Real axis');
t.FontSize = 15;
t = text(0.2,y2*0.9,'Imaginary axis');
t.FontSize = 15;
axis square
17 changes: 17 additions & 0 deletions 고려대학교zoom강의/210524lecture/fun_plotNumberLine.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
function fun_plotNumberLine(x1,x2,h_newfig)

if h_newfig
figure;
set(gcf,'position',[500,100,1000,650])
set(gcf,'color','w');
end
set(gca,'visible','off')
mArrow2(x1-1,0,x2+1,0,{'color','k'});
xlim([x1-1 x2+1])
ylim([-1 1])

for i = x1:x2
line([i i],[-0.025 0.025],'color','k')
t= text(i-0.1, -0.1,num2str(i));
t.FontSize=15;
end
9 changes: 9 additions & 0 deletions 고려대학교zoom강의/210524lecture/mArrow2.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

function [ h ] = mArrow2(x1,y1,x2,y2,props)

h = annotation('arrow');
set(h,'parent', gca, ...
'position', [x1,y1,x2-x1,y2-y1], ...
'HeadLength', 10, 'HeadWidth', 10, 'HeadStyle', 'cback1', ...
props{:});
end
138 changes: 138 additions & 0 deletions 고려대학교zoom강의/210524lecture/pics.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
clear; close all; clc;

%% 3을 수직선 상에 표현해주는 그림

clear v
v = VideoWriter('fig1.mp4','MPEG-4');
v.FrameRate = 50;
v.Quality = 100;
open(v);

clear F

fun_plotNumberLine(-4,4,true)
hold on;
the_num = 3;
n_step = 50;
for i_step = 1:n_step


len_arrows = linspace(1, the_num, n_step);
len_arrow = len_arrows(i_step);

h = mArrow2(0,0,len_arrow,0,{'color','r','linewidth',3});
F(i_step)=getframe(gcf);

drawnow;
if i_step < n_step
delete(h)
end
end


for i=1:length(F)
% convert the image to a frame
frame = F(i) ;
writeVideo(v, frame);
end

close(v)


%% -3을 수직선 상에 표현해주는 그림

clear v
v = VideoWriter('fig2.mp4','MPEG-4');
v.FrameRate = 50;
v.Quality = 100;
open(v);

clear F

fun_plotNumberLine(-4,4,true)
hold on;
the_num = -3;
n_step = 50;
for i_step = 1:n_step


len_arrows = linspace(1, the_num, n_step);
len_arrow = len_arrows(i_step);

h = mArrow2(0,0,len_arrow,0,{'color','r','linewidth',3});
F(i_step)=getframe(gcf);

drawnow;
if i_step < n_step
delete(h)
end
end


for i=1:length(F)
% convert the image to a frame
frame = F(i) ;
writeVideo(v, frame);
end

close(v)

%% 3x3을 수직선 상에 표현해주는 그림

clear v
v = VideoWriter('fig3.mp4','MPEG-4');
v.FrameRate = 50;
v.Quality = 100;
open(v);

clear F

fun_plotNumberLine(-4,10,true)
hold on;
the_num = 3;
n_step = 50;
for i_step = 1:n_step


len_arrows = linspace(1, the_num, n_step);
len_arrow = len_arrows(i_step);

h = mArrow2(0,0,len_arrow,0,{'color','r','linewidth',3});
F(i_step)=getframe(gcf);

drawnow;
if i_step < n_step
delete(h)
end
end

for i = 1:10
F(end+1) = getframe(gcf);
end

delete(h)

for i_step = 1:n_step


len_arrows = linspace(the_num, the_num^2, n_step);
len_arrow = len_arrows(i_step);

h = mArrow2(0,0,len_arrow,0,{'color','r','linewidth',3});
F(end+1)=getframe(gcf);

drawnow;
if i_step < n_step
delete(h)
end
end


for i=1:length(F)
% convert the image to a frame
frame = F(i) ;
writeVideo(v, frame);
end

close(v)

99 changes: 99 additions & 0 deletions 고려대학교zoom강의/calculus.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
clear; close all; clc;


%% Fig 3. 한 점 (x,y)에서 순간 변화율과 평균 변화율 (동영상)
for x1 = [1, 0.5, 0.1]+1
plotXY(-1,3,-1,3,true,20)
x = linspace(-1,3, 100);
y = 1/3*x.^2 + 1;
hold on;
plot(x,y,'k','linewidth',2)

x = linspace(-0.5, 2.5, 100);

plot(x, 2/3*x + 2/3,'b','linewidth',3)
plot(1, 4/3 ,'o','markerfacecolor','b','markeredgecolor','none','markersize',10)

y1 = 1/3 * x1^2 + 1;

y = (y1-4/3)/(x1-1) * (x-1) + 4/3;
h(1) = plot(x1, y1, 'o', 'markerfacecolor','r','markeredgecolor','none','markersize',10);
h(2) = plot(x, y, 'r','linewidth',3);

end


%% Fig 3. 한 점 (x,y)에서 순간 변화율과 평균 변화율 (동영상)
clear v
v = VideoWriter('fig3.mp4','MPEG-4');
v.FrameRate = 30;
v.Quality = 100;
open(v);

clear F

plotXY(-1,3,-1,3,true,20)
x = linspace(-1,3, 100);
y = 1/3*x.^2 + 1;
hold on;
plot(x,y,'k','linewidth',2)

x = linspace(-0.5, 2.5, 100);

plot(x, 2/3*x + 2/3,'b','linewidth',3)
plot(1, 4/3 ,'o','markerfacecolor','b','markeredgecolor','none','markersize',10)

i=1;
for x1 = linspace(3,1,100)


y1 = 1/3 * x1^2 + 1;

y = (y1-4/3)/(x1-1) * (x-1) + 4/3;
h(1) = plot(x1, y1, 'o', 'markerfacecolor','r','markeredgecolor','none','markersize',10);
h(2) = plot(x, y, 'r','linewidth',3);
drawnow;

F(i)=getframe(gcf);
if x1>1
delete(h)
end
i=i+1;
end


for i=1:length(F)
% convert the image to a frame
frame = F(i) ;
writeVideo(v, frame);
end

close(v)

%% 3d plot

close all;
[X,Y] = meshgrid(linspace(-3,3,20));

surf(X, Y, -X.^2-Y.^2+1)
xlabel('$$x$$','interpreter','latex'); ylabel('$$y$$','interpreter','latex'); zlabel('$$z=-x^2-y^2+1$$','interpreter','latex');
hold on;
xx = -1 * ones(1,100);
yy = linspace(-3,3,100);
zz = -xx.^2 - yy.^2 + 1;
plot3(xx,yy,zz,'r','linewidth',3)

% tangential line
% (-1, -1, -1)에서...?
% round z round y = - 2y
t = linspace(-0.5,1,100);

x = -1 * ones(1, 100);
y = -2 + 4 * t;
z = -4 + 16*t

plot3(x,y,z,'k','linewidth',3);
plot3(-1,-2,-4,'o','markersize',7,'markerfacecolor','k','markeredgecolor','none')

axis square

Binary file added 고려대학교zoom강의/fig3.mp4
Binary file not shown.
27 changes: 27 additions & 0 deletions 고려대학교zoom강의/intro_plots.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
clear; close all; clc;

%%

x1 = randn(1, 100) * 4 + 10;
x2 = randn(1, 100) * 4 + 25;

x1(x1<0) = abs(x1(x1<0));
x2(x2<0) = abs(x2(x2<0));
rng(1)
figure('position',[1000, 650, 700, 350]);
histogram(x1);
hold on;
histogram(x2);
xlabel('귀의 길이(cm)');
ylabel('count');
title('고양이와 강아지의 귀의 길이를 통한 구별');
grid on;

figure;

plot(x1, 0,'o','markerfacecolor','b','markeredgecolor','none');
hold on;
plot(x2,0,'o','markerfacecolor','r','markeredgecolor','none');

xlabel('귀의 길이(cm)');
title('귀의 길이 데이터를 1차원 벡터 공간 상에 매핑');
Loading

0 comments on commit 5bce31f

Please sign in to comment.