달력

3

« 2024/3 »

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31

'종료/수치해석'에 해당되는 글 2

  1. 2009.03.24 2장. MATLAB 그래픽
  2. 2009.03.21 행벡터, 열벡터
2009. 3. 24. 15:35

2장. MATLAB 그래픽 종료/수치해석2009. 3. 24. 15:35

x=0:0.01:10;
y = exp(-0.5*x).*sin(5*x);

%그리기
plot(x,y)

%선만 바꾸어 그리기.
set(plot(x,y), 'LineStyle','--')

%점만 그리기
plot(x,y,'+')

plot(x,y,'r-.', x, y, 'ob')

axis([4,8,-0.3,0.3])

grid on   % grid만으로 토글 가능

xlabel('x');
ylabel('y');
title('aslkdfjasdfj');

print -dbimap ex1.bmp

% 그냥 plot과 별다를게 없지만 분할만 해준다.
subplot(221); % 이 때까지는 사분면에서 그림은 하나만그려짐.
subplot(222);
subplot(2,2,2);
subplot(223);
subplot(224);

% pi는 상수..
>> t=0:0.1:100;
>> x=1+0.5*exp(-0.05*t).*sin(t+pi/2);


x1=0:0.1:10;
y1=x1.^2 + 1;
x2=0:0.1:10;
y2=sin(sqrt(x2))./exp(x2)
plotyy(x1,y1,x2,y2)

t=0:900; A=1000; a=0.005; b=0.005;
z1=A*exp(-a*t);
z2=sin(b*t);
[haxes,hline1,hline2] = plotyy(t,z1,t,z2,'semilogy','plot');
axes(haxes(1))
ylabel('Semilog Plot');
axes(haxes(2))
ylabel('Linear Plot');
set(hline2,'LineStyle','--')

x=0:0.1:10;
y1=cos(x);
y2=1+cos(x);
y3=2+cos(x);
y4=3+cos(x);
plot(x,y1,'g-',x,y2,'b--',x,y3,'r:',x,y4,'k-.')

t=0:1:10;
x=0.5*exp(-0.5*t).*sin(t+pi/2);
plot(t,x,'b-.diamond');

%다음 두 문장은 색상과 선 타입만 빼고는 같다
plot(t,x,'b-.o');
plot(t,x,'-r',x,y,'ok');

% 그래프 겹붙일때 둘 사이에 넣는다
hold on
hold off

x=0:0.01:10;
y=exp(-0.5*x).*sin(5*x);
plot(x,y)
v=[0,6,-0.2,0.6];
axis(v)
v=[0,2,4,6,8,10];
set(gca,'xtick',v);    % change only tick, not scale
v=[-1.0,-0.5,0,0.5,1.0];
set (gca,'ytick',v);


t = linspace(0,2*pi,30)
x1=sin(t);
x2=cos(t);
plot(t,x1,'b-', t, x2,'r--')
legend('sin','cos');
text(1.5,0.5,'x1=sin(t)\rightarrow');
% 반드시 마우스로 클릭할것..
gtext('\ite^{i\omega\tau} = cos(\omega\tau)+i sin(\omega\tau)')

linspace(0,300);    % 자동으로 100개 value 생성
x=sin(t);
y=cos(t);
plot3(x,y,t);
xlabel('sin(t)');
x=-7.5:.5:7.5;
y=x;
[X,Y] = meshgrid(x,y);
R=sqrt(X.^2+Y.^2)+eps;
Z=sin(R)./R
size(Z)
mesh(X,Y,Z);
colorbar;

surf(X,Y,Z) % replace with meshc, surfc, pcolor
shading flat
contour(X,Y,Z,20);   % 등고선 20줄로 나눠 표현
contour(X,Y,Z,20.1); % 특 정 값에 대한 등고선 한줄.

[C,h] = contour(Z,10);
clabel(C,h) % 등고선 마다 값을 그래프에 직접 찍어준다.

[C,h]=contour3(X,Y,Z,20);
%% h =findobject('Type','patch'); % alternative
set(h,'LineWidth',2);

mesh(peaks(20)+7)
hidden off
hidden on


>> figure
>> Z=peaks;
>> caxis([-20 20]); % contour axis??

>> [C,h] = contourf(Z,20); % contourFILL
:
Posted by Kwang-sung Jun
2009. 3. 21. 16:49

행벡터, 열벡터 종료/수치해석2009. 3. 21. 16:49


예를 들어 위의 행렬에서는
\begin{bmatrix} 1 & 2 & 3 \end{bmatrix}, \begin{bmatrix}4 & 5 & 6 \end{bmatrix}

가 행벡터,

\begin{bmatrix} 1 \\ 4 \end{bmatrix}, \begin{bmatrix} 2 \\ 5 \end{bmatrix}, \begin{bmatrix} 3 \\ 6 \end{bmatrix}

가 열벡터가 된다.

:
Posted by Kwang-sung Jun