<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet href="http://rss.egloos.com/style/blog.xsl" type="text/xsl" media="screen"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
	<title>Pis Workshop</title>
	<link>http://pandland.egloos.com</link>
	<description>블로그 시작이다!</description>
	<language>ko</language>
	<pubDate>Mon, 01 Sep 2008 02:21:10 GMT</pubDate>
	<generator>Egloos</generator>
	<image>
		<title>Pis Workshop</title>
		<url>http://pds.egloos.com/logo/1/  </url>
		<link>http://pandland.egloos.com</link>
		<width>80</width>
		<height>80</height>
		<description>블로그 시작이다!</description>
	</image>
  	<item>
		<title><![CDATA[ awk ]]> </title>
		<link>http://pandland.egloos.com/4390368</link>
		<guid>http://pandland.egloos.com/4390368</guid>
		<description>
			<![CDATA[ 
  awk '{print "use ",$1,";save/file=temp.nc/append zeta; cancel data/all"}' filename.txt &gt; merge.csh<br><br>사용시 filename.txt에서 문자열 한줄씩 읽어와서 $1이 되어 있는 부분이 그 문자열로 대체되어<br>print문 안에 있는 내용이 merge.csh에 반복되어 출력된다.<br><br>이 경우 filename에는&nbsp;ls의 결과물들이 들어간다.			 ]]> 
		</description>
		<category>Linux</category>

		<comments>http://pandland.egloos.com/4390368#comments</comments>
		<pubDate>Thu, 29 May 2008 16:26:51 GMT</pubDate>
		<dc:creator>pandland</dc:creator>
	</item>
	<item>
		<title><![CDATA[ Proftp 설치 및 방화벽 설정, 하드디스크 추가 ]]> </title>
		<link>http://pandland.egloos.com/4390363</link>
		<guid>http://pandland.egloos.com/4390363</guid>
		<description>
			<![CDATA[ 
  수세 리눅스 10.2 기준<br>SSH(Open ssh2)와 FTP서버(proftp)를 구축하는 방법<br><br>프로그램 설치, 부팅 파일 변경 등의 작업시 관리자 권한이 필요하다<br><br>&gt;&gt; su<br>- 관리자 암호 입력<br><br>관리자 로그인이 된 상태에서 작업이 이뤄져야 한다.<br><br><br><br>1. gcc 설치<br>-&gt; 알아서 한다 -_-<br><br>2. proftp 설치<br><a href="http://www.proftpd.org/" target="_blank">http://www.proftpd.org</a> 접속<br>다운로드(gz버전이 낫겠지? -_-)<br>(/usr/local/ 에 압축파일이 있다고 가정했을때)<br>&gt;&gt; tar xvf proftpd-1.3.0a.tar.gz<br>&gt;&gt; rm proftpd-*.tar.gz<br>&gt;&gt; cd proftpd-1.3.0a<br>&gt;&gt; ./configure --prefix=/usr/local/proftpd<br>&gt;&gt; make<br>&gt;&gt; make install<br>&gt;&gt; cd /usr/local/<br>&gt;&gt; rm -rf proftpd-*<br>(설치완료)<br><br>3. 부팅시 자동실행파일 조절<br>&gt;&gt; vi /etc/rc.d/boot.local (안되면 boot.local 대신 rc.local)<br>&gt;&gt; 파일의 가장 아랫줄에 다음의 내용을 적는다<br><br>iptables -F<br>iptables -P INPUT DROP<br>iptables -P OUTPUT ACCEPT<br>iptables -P FORWARD DROP<br><br>iptables -A INPUT -i lo -j ACCEPT<br><br>iptables -A INPUT -i eth0 -p tcp ! --syn -j ACCEPT<br><br>iptables -A INPUT -i eth0 -p tcp --source-port 53 -j ACCEPT<br>iptables -A INPUT -i eth0 -p udp --source-port 53 -j ACCEPT<br><br>iptables -A INPUT -i eth0 -p tcp --destination-port 113 -j REJECT<br><br>iptables -A INPUT -i eth0 -p icmp --icmp-type 0 -j ACCEPT<br>iptables -A INPUT -i eth0 -p icmp --icmp-type 3 -j ACCEPT<br>iptables -A INPUT -i eth0 -p icmp --icmp-type 11 -j ACCEPT<br><br>iptables -A INPUT -p tcp --dport 21 -j ACCEPT<br>iptables -A INPUT -p tcp --dport 22 -j ACCEPT<br><br>/usr/local/proftpd/sbin/proftpd<br><br><br>-- 사용자 설정 등은 알아서 한다 -_-<br><br><br><br><br>4. 하드 디스크 추가<br><br>&gt;&gt; fdisk -l<br>-&gt; 여기서 /dev/hda1, 등과 같이 장치 이름이 전부 나오게 된다. 이걸 싸그리 포맷해야 함(물론 리눅스가 설치된 주 하드는 건드리면 안된다 -_-;<br><br>&gt;&gt; mkfs.ext3 /dev/hdc1<br>-&gt; 하드 ext3 타입으로 포맷<br><br>&gt;&gt; mount -t ext3 /dev/hdc1 /home/backup1<br>-&gt; 요로코롬 마운트 가능하다 -_- 물론 /home/backup1 이라는 경로가 존재해야 함<br><br>&gt;&gt; vi /etc/fstab<br>/dev/sdb1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /home&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ext3&nbsp;&nbsp;&nbsp;&nbsp;defaults&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1 1 <br>와 같은 식으로 하드 있던것들 전부 맞게 추가시켜줌<!--"<-->			 ]]> 
		</description>
		<category>Linux</category>

		<comments>http://pandland.egloos.com/4390363#comments</comments>
		<pubDate>Thu, 29 May 2008 16:24:35 GMT</pubDate>
		<dc:creator>pandland</dc:creator>
	</item>
	<item>
		<title><![CDATA[ WinXP에서 SATA2 하드 제대로 쓰게 하기 ]]> </title>
		<link>http://pandland.egloos.com/4390361</link>
		<guid>http://pandland.egloos.com/4390361</guid>
		<description>
			<![CDATA[ 
  1. BIOS에서 SATA as [IDE] 모드로 설정. (BIOS에 따라서 약간 다를수 있음)<br><br>2. Windows XP/2003 등을 정상적인 방법으로 설치. (이런저런 칩셋 패치도 모두 해줌)<br><br>3. 자신의 M/B 칩셋 이름의 정확한 명칭을 알기 위하여 Intel Chipset Identification Utility (chiputil.exe)를 다운 받아서 확인합니다. <br><br>4. www.intel.com에서 Intel Matrix Storage Manager (iata60_cd.exe(Multi Language Version))도 다운받습니다. <br><br>5. "iata60_cd.exe -a -a -pc:\temp" 를 command line 명령어로 실행하면 c:\temp 밑에 file들이 풀려 나옴. (참고:이 프로그램을 그냥 실행하면 칩셋이 않맞다고 설치가 안됩니다.)<br><br>6. 장치관리자에서 IDE ATA/ATAPI controllers 밑에 Intel(R) 82801 XX Serial ATA...가 있음.<br><br>7. 이것의 등록정보에서 Update Driver(또는 이와 유사한 버튼)를 누르고 적당히 선택하여 조금전에 풀린 C:\Temp\Driver에 있는 iaahci.inf를 지정해줌.<br><br>8. 자신의 M/B 칩셋 이름을 선택해 줌. (예: Intel (R) 82801 GR/GH SATA AHCI Controller)<br><br>9. 뭐라뭐라 경고가 뜨면 무시함.<br><br>10. 컴퓨터 종료.<br><br>0. BIOS 셋업으로 들어가서 SATA as [IDE]를 SATA as [AHCI]로 변경함.<br><br>11. 재부팅.<br><br>12. iata60_cd.exe을 실행하여 Intel Matrix Storage Manager를 정상적으로 설치하고, 설치된 Matrix Storage Console프로그램을 실행하여 NCQ가 정상적으로 동작하는지 확인. (한글로 NCQ를 "기본 명령어 대기열 삽입 지원"(???) 이라고 번역해놓았네요)<br><br>출처 - 네이버 모 블로그 -_-;<!--"<-->			 ]]> 
		</description>
		<category>Matlab &amp; etc</category>

		<comments>http://pandland.egloos.com/4390361#comments</comments>
		<pubDate>Thu, 29 May 2008 16:23:29 GMT</pubDate>
		<dc:creator>pandland</dc:creator>
	</item>
	<item>
		<title><![CDATA[ gzip, tar ]]> </title>
		<link>http://pandland.egloos.com/4390360</link>
		<guid>http://pandland.egloos.com/4390360</guid>
		<description>
			<![CDATA[ 
  <span style="LINE-HEIGHT: 160%">&nbsp;<table style="TABLE-LAYOUT: fixed" cellspacing="0" cellpadding="0" width="100%" border="0"><colgroup><col width="100%"></col><tbody><tr><td valign="top">shell&gt; gzip -9 filename.tar<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# filename.tar파일이 압축되어 filename.tar.gz이라는 파일 압축된다.<br><br>shell&gt; gzip -d filename.tar.gz or gunzip filename.tar.gz<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# filename.tar.gz파일이 압축해제되어 filename.tar 로 된다.<br><br><br><br><br>shell&gt; tar cvzf root.tgz root/<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# tar로 압축한후 다시 gzip으로 압축하는 두 과정의 번거러움을 피하고자 tar의 명령어에 z옵션을 추가하여 파일을 압축하면서 아카이브 한다. 이 경우 확장자가 tgz을 사용함으로써 의미를 구분한다.<br><br>shell&gt; tar xvzf root.tgz<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# tar의 명령으로 아카이브된 파일을 풀면서 z 옵션을 추가햐여 압축을 해제한다.<br><br>출처 : <a href="http://blog.naver.com/whatsgoingon?Redirect=Log&amp;logNo=110002386054" target="_blank">http://blog.naver.com/whatsgoingon?Redirect=Log&amp;logNo=110002386054</a><br><br><br>구 IBM 머신 등에서 gz tar 한번에 풀기..<br>gzip -dc a.tar.gz | tar xvf -<!--"<--></td></tr></tbody></table></span>			 ]]> 
		</description>
		<category>Linux</category>

		<comments>http://pandland.egloos.com/4390360#comments</comments>
		<pubDate>Thu, 29 May 2008 16:22:52 GMT</pubDate>
		<dc:creator>pandland</dc:creator>
	</item>
	<item>
		<title><![CDATA[ tta/cue 파일 사용법 ]]> </title>
		<link>http://pandland.egloos.com/4390355</link>
		<guid>http://pandland.egloos.com/4390355</guid>
		<description>
			<![CDATA[ 
  <span style="LINE-HEIGHT: 160%">&nbsp;<table style="TABLE-LAYOUT: fixed" cellspacing="0" cellpadding="0" width="100%" border="0"><colgroup><col width="100%"></col><tbody><tr><td valign="top">준비물 : Tau Producer라는 수상한(...) 프로그램<br><br>암흑의 경로를 뒤져보다보면 간혹 tta라는 상당히 낯선 형태의 모양으로 하고 있는 파일을 볼 수 있을 것이다. 보통 앨범 전체가 하나로 되어있는데... 시디 한장의 이미지라고 생각하면 편하겠다..<br><br>Tau Producer라는 프로그램은 알아서 구하도록 한다. 참고로 설치 파일명은 wintta-setup.exe<br><br><br>Tau Producer를 실행하여 tta 파일을 불러들이고 Processing 명령을 내리게되면 알아서 WAV파일로 바꿔준다.<br><br>여기서! 중요한거...<br><br>보통 바꾸게 되면 tta파일의 파일명을 취하면서 파일 확장자가 wav인 파일이 생성되어 있을 것이다.<br>우리는 이 wav파일이 필요하다. tta는 지워도 상관없다(-_-!)<br><br>그리고 cue 파일을 열어보자.<br><br>안에 뭐라뭐라 많이 적혀 있을건데... ~~~.tta라는 부분이 존재할 것이다.<br>여기 있는 놈을 ~~~.wav로 바꿔준다.<br><br>그러면 cue파일을 데몬에서 열 수 있다!<br>그러면 이제 음악시디를 시디롬 드라이브에 넣은것과 완전 동일하다!<br>이제 MP3를 뜨든가 그냥 미디어 플레이어로 듣든가... 지 맘대로 하자...-_-<br><br>끝...<!--"<--></td></tr></tbody></table></span><br>출처 : 이것도 여기저기 돌아다니면서 취합한 내용이라... 죄송-_)			 ]]> 
		</description>
		<category>Matlab &amp; etc</category>

		<comments>http://pandland.egloos.com/4390355#comments</comments>
		<pubDate>Thu, 29 May 2008 16:21:20 GMT</pubDate>
		<dc:creator>pandland</dc:creator>
	</item>
	<item>
		<title><![CDATA[ Fedora core6 메일서버 구축 ]]> </title>
		<link>http://pandland.egloos.com/4390349</link>
		<guid>http://pandland.egloos.com/4390349</guid>
		<description>
			<![CDATA[ 
  요 3일간 삽질 끝에 Sendmail과 Dovecot을 이용한 메일서버 구축에 성공했다...ㅜㅜ<br>당연히 기술문서를 남겨야지-_-;;<br><br><br>1. 설치<br>필요 프로그램 sendmail, sendmail-cf, dovecot<br>설치 방법 yum -y install sendmail sendmail-cf dovecot<br>(제거시 install대신 remove)<br><br>2. 컨피그 설정<br>1) local-host-names<br># vi /etc/mail/local-host-names<br><br>주석글 밑에 서버의 도메인을 적어줌<br><br>2) sendmail.mc, sendmail.cf<br># vi /etc/mail/sendmail.mc<br><br>SMTP-AUTH를 사용하지 않으므로 딱히 고칠것은 없다.<br>... Port=smtp, Addr=127.0.0.1 .... 부분에서 주소를 0.0.0.0으로만 수정<br><br># m4 /etc/mail/sendmail.mc -&gt; /etc/mail/sendmail.cf<br><br>3) access<br># vi /etc/mail/access<br><br>추가할 주소 적어주고 탭으로 띄운 후 RELAY<br><br># makemap hash /etc/mail/access &lt; /etc/mail/access<br><br>4) dovecot.conf<br>#vi /etc/dovecot.conf<br><br>protocols = pop3로 수정 및 주석 풀기<br>mail_location = ... mbox있는걸로 수정-_- 및 주석 풀기<br><br>5) 권한, 경로 설정<br>home이하의 사용자 폴더의 소유자는 각 사용자명으로 되어 있어야 함<br>권한은 dwrx..... 이상<br>혹시 안되면 사용자 폴더 아래에 mail 폴더를 생성<br><br>3. 실행<br><br>/etc/rc.d/init.d/sendmail start<br>/etc/rc.d/init.d/dovecot start...<br><br>4. 혹시라도 방화벽으로 막혀 있다면..-_-<br><br># 우선 모든 Rule을 정리한다.<br>/sbin/iptables -F<br><br># 다음으로 각각에 대한 정책을 세운다.<br>/sbin/iptables -P INPUT DROP<br>/sbin/iptables -P OUTPUT ACCEPT<br>/sbin/iptables -P FORWARD DROP<br><br># localhost에서의 traffic을 받아들인다.<br>/sbin/iptables -A INPUT -i lo -j ACCEPT<br><br># 확립된 연결에 대한 Packet을 받아들인다.<br>/sbin/iptables -A INPUT -i eth0 -p tcp ! --syn -j ACCEPT<br><br># DNS 응답을 받아들인다.<br>/sbin/iptables -A INPUT -i eth0 -p tcp --source-port 53 -j ACCEPT<br>/sbin/iptables -A INPUT -i eth0 -p udp --source-port 53 -j ACCEPT<br><br># 인증 연결을 거부한다(그렇지 않을 경우 메일서버가 오랫동안 타임아웃 상태가 될 것이다.)<br>/sbin/iptables -A INPUT -i eth0 -p tcp --destination-port 113 -j REJECT<br><br># echo나 목적지에 도착 못하거나 시간 초과된 icmp packet들을 받아들인다.<br>/sbin/iptables -A INPUT -i eth0 -p icmp --icmp-type 0 -j ACCEPT<br>/sbin/iptables -A INPUT -i eth0 -p icmp --icmp-type 3 -j ACCEPT<br>/sbin/iptables -A INPUT -i eth0 -p icmp --icmp-type 11 -j ACCEPT<br><br># ssh 열기<br>/sbin/iptables -A INPUT -p tcp --dport 22 -j ACCEPT<br><br># POP3 열기<br>/sbin/iptables -A INPUT -p tcp --dport 110 -j ACCEPT<br><br># Sendmail 열기<br>/sbin/iptables -A INPUT -p tcp --dport 25 -j ACCEPT<br><br><br>* 혹시 yum과 시스템 자체 프로그램 추가/제거 기능이 작동하지 않으면 yum.pid 파일을 삭제할것..<br><br>- 출처 : 네이버의 수많은 블로그들...(필요한것만 딱 뽑아내어 취합했다..-_-) <br><!--"<-->			 ]]> 
		</description>
		<category>Linux</category>

		<comments>http://pandland.egloos.com/4390349#comments</comments>
		<pubDate>Thu, 29 May 2008 16:19:15 GMT</pubDate>
		<dc:creator>pandland</dc:creator>
	</item>
	<item>
		<title><![CDATA[ Fortran 90 compile ]]> </title>
		<link>http://pandland.egloos.com/4390345</link>
		<guid>http://pandland.egloos.com/4390345</guid>
		<description>
			<![CDATA[ 
  <p>편의상 gfortran, ifort 등의 90 용 컴파일러를 아울러 f90이라고 정의한다...-_-;<br><br>단순 컴파일<br>f90 source.f90 -o execute.exe<br><br>파일이 많은 경우...<br>main이 되는 코드 파일을 뒤로 배치하여 소스파일명을 나열한다.<br>f90 source1.f90 source2.f90 main.f90 -o execute.exe<br><br>netcdf 컴파일<br>f90 source.f90 -o execute.exe -I(netcdf include directory) -L(netcdf library directory) -lnetcdf<br><br><br>추후 현재 사용하고 있는 makefile을 하나 가져와 아래에 makefile 예를 붙일 예정</p>			 ]]> 
		</description>
		<category>Linux</category>

		<comments>http://pandland.egloos.com/4390345#comments</comments>
		<pubDate>Thu, 29 May 2008 16:17:46 GMT</pubDate>
		<dc:creator>pandland</dc:creator>
	</item>
	<item>
		<title><![CDATA[ vi ]]> </title>
		<link>http://pandland.egloos.com/4390333</link>
		<guid>http://pandland.egloos.com/4390333</guid>
		<description>
			<![CDATA[ 
  <p>문서 편집기 vi...<br><br>마우스를 이용한 인터페이스의 문서편집기에 너무나 익숙해진 요즘..<br>오직 키보드만 가지고 모든것을 컨트롤 해야 하는 vi는 약간 어렵다..-_-;<br><br>여기서는 vi 사용할 때 기본적인 부분들을 정리...<br><br><br>vi (filename) : vi 가동... 파일 존재시 편집, 없으면 생성<br><br>i : input모드 (esc로 해제 가능, 해제시 커서 위치가 한칸 왼쪽으로 옮겨간다.)<br><br>:w 저장<br>:q 나가기<br>:wq 와 같이 한번에 사용 가능<br>!를 붙여 명령을 실행할 수 없는 상태에서도 강제로 수행 가능..(파일 내용을 바꿨지만 저장하지 않고 나갈때 :q!)<br><br>ctrl + f :&nbsp;page down<br>ctrl + b : page up<br>shift + g : end<br><br>x : 한글자 지우기<br>r : 입력 직후 입력된 문자로 한문자 바꾸기<br>dd : 한줄 지우기<br>dw : 한 단어 지우기<br><br>x나 dd등을 사용하기 전에 숫자 입력하면 그 숫자만큼 명령이 반복실행됨..<br><br>:%s/^M//g : ^M 기호 일괄 삭제(ctrl + v, ctrl + m 으로 입력된 문자)<br><br>* vi는 아직 모르는 부분이 많으므로 계속 업데이트 됩니다.</p>			 ]]> 
		</description>
		<category>Linux</category>

		<comments>http://pandland.egloos.com/4390333#comments</comments>
		<pubDate>Thu, 29 May 2008 16:09:59 GMT</pubDate>
		<dc:creator>pandland</dc:creator>
	</item>
	<item>
		<title><![CDATA[ 시간 설정 ]]> </title>
		<link>http://pandland.egloos.com/4390318</link>
		<guid>http://pandland.egloos.com/4390318</guid>
		<description>
			<![CDATA[ 
  <p><span style="LINE-HEIGHT: 160%">&nbsp;<table style="TABLE-LAYOUT: fixed" cellspacing="0" cellpadding="0" width="100%" border="0"><colgroup><col width="100%"></col><tbody><tr><td valign="top"># date [MMDDhhmm[[CC]YY][.ss]<br><br><br>맞추려는 시간이 2004년 07월 15일 오후 4시 15분 50초라면<br><br># date 071516152004.50<br><br><br>타임서버<br><br>time.bora.net<br>time.kriss.re.kr -- 주로 refuse .<br><br><br>타임서버 시간 보기 <br><br><br><br># rdate -p time.bora.net<br><br><br><br>타임서버 시간을 로컬 시간으로 <br><br><br><br># rdate -s time.bora.net&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br><br><br><br>확인<br><br><br><br># date<br><br>* 출처 : <a href="http://blog.naver.com/2jaekoo" target="_blank">http://blog.naver.com/2jaekoo</a><br><br>* 내가 이용하는 buoy 서버의 경우 rdate 명령어가 먹히지 않음... </td></tr></tbody></table></span></p>			 ]]> 
		</description>
		<category>Linux</category>

		<comments>http://pandland.egloos.com/4390318#comments</comments>
		<pubDate>Thu, 29 May 2008 16:04:02 GMT</pubDate>
		<dc:creator>pandland</dc:creator>
	</item>
	<item>
		<title><![CDATA[ Matlab 강좌 1 ]]> </title>
		<link>http://pandland.egloos.com/3173602</link>
		<guid>http://pandland.egloos.com/3173602</guid>
		<description>
			<![CDATA[ 
  <span style="COLOR: #ff0000">1. 행렬, 벡터 표현<br />
</span>2. 기본명령어 소개<br />
3. 함수 작성 및 이용<br />
4. File Control<br />
5. Plot<br />
6. Contour<br />
7. Feather plot, Quiver plot<br />
8. Graphic Handling<br />
9. 경사면 실험(Inclined Plane Problem)<br />
10. 지도 위의 해양자료 표현<br />
11. CTD 자료 처리<br />
12. 지형류 계산<br />
<br />
사실 2월 중에 절반 정도의 강좌를 마치려고 했는데... 이것저것 일도 많았고 귀찮았던 것도 있고 해서... 하지를 못했다. 이미 발등에 불이 떨어진 관계로... 일단 강좌를 얼른 진행하도록 하겠다 -_-<br />
<br />
------------------------------------------------------------------------------<br />
<br />
Matlab에서는 행렬로 대부분의 자료를 처리한다고 했다.<br />
여기서 행렬이 뭔가?, 벡터가 뭔가? 하는 문제는 다룰 필요가 없을 것 같다. 단지 Matlab에서 어떻게 행렬을 만들어내고 다루는가 하는 문제만 다루면 충분할 것이라 본다. 혹시 잘 모르겠다면... 고등학교 수학을 조금 본다든가... 대학생이라면 선형대수를 조금 배워보는 것도 좋을 것이다.<br />
<br />
<br />
<strong>-&nbsp;'=' 연산자</strong><br />
약간 주제와는 다른 부분이지만 워낙 핵심적인 부분이라 다루고 넘어간다.<br />
'=' 이라고 해서 이모티콘처럼 보이는데... 그냥 =(equal)을 뜻한다. 프로그래밍을 접해보지 못한 분들은 다음과 같은 일련의 식을 보고 적잖아 당황한다.<br />
<br />
<em>a = 5;</em><br />
<em>a = a + 2;</em><br />
<br />
a = a + 2에서 아마 당황할 것이다. 그러나 고등학교 수학에서도 잠깐 배웠듯이 a = a + 2가 a와 a+2가 같다는 뜻이 아니라... a + 2라는 내용을 a에다 집어넣는다는 뜻이다. 그러므로 저 위의 식들의 결과 a는 7이라는 값을 가지게 된다. 실제로 대다수의 프로그래밍 언어에서 '같다'라는 뜻을 나타낼 때는 '=='라는 기호를 사용한다.<br />
<br />
<br />
<strong>- 행렬 생성</strong><br />
우리가 다루는 대부분의 행렬은 2차 행렬과 벡터이다. 간단하게 설명하자면 행렬은 다음과 같이 선언할 수 있다.<br />
<br />
<em>a = [1 1 1; 2 2 2];</em><br />
<br />
Matlab에서 위와 같은 명령을 내리면 아래와 같은 행렬이 만들어진다.<br />
<br />
1 1 1<br />
2 2 2<br />
<br />
즉 대괄호([ ])에서 세미콜론(;)으로 분할되어 있는 성분들이 모두 행렬의 가로성분이 되고, 세미콜론으로 분할된 단위마다 세로로 성분들이 쌓이게 되는 것이다. 참고로 이 행렬의 성분을 골라서 쓸 때는 아래와 같이 한다.<br />
<br />
<em>b = a(1,2);</em><br />
<br />
2차 행렬이므로 괄호를 이용하여 2개의 좌표를 넣어주는 것이다. 그러면 b에는 뭐가 들어갈까?<br />
<span style="COLOR: #3333ff">정답은 1이다.</span><br />
<br />
즉, 2개의 좌표를 넣어줄 때 먼저 넣어주는 좌표가 세로 성분의 위치이고 나중에 넣어주는 좌표가 가로 성분의 위치임을 알 수 있다.<br />
<br />
<em>b = a(2,1);</em><br />
<br />
을 하면 당연히 결과는 2가 나온다.<br />
<br />
벡터의 경우 일반적으로 선형대수 시간에 배울때는 (1, 2, 3)^t와 같은 형태로 배웠을 것이다. 즉, 성분들이 '세로'로 배열되어 있다. 하지만 Matlab에서는 일반적으로 벡터를 선언할 때 가로로 만든다. 하지만 실제로 행렬간의 곱셈등을 쓸 때는 실제 선형대수의 형태로 해줘야 한다.<br />
<br />
위의 a에서 b = [1 2 3]이라고 선언된 것과 c = [1;2;3]이라고 선언된 것을 가지고 각각 a와 곱해보려하면 다음과 같은 결과가 나타난다.<br />
<br />
&gt;&gt; b = [1 2 3]<br />
b =<br />
&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp;&nbsp;&nbsp;&nbsp; 2&nbsp;&nbsp;&nbsp;&nbsp; 3<br />
&gt;&gt; c = [1;2;3]<br />
c =<br />
&nbsp;&nbsp;&nbsp;&nbsp; 1<br />
&nbsp;&nbsp;&nbsp;&nbsp; 2<br />
&nbsp;&nbsp;&nbsp;&nbsp; 3<br />
&gt;&gt; a*b<br />
??? Error using ==&gt; mtimes<br />
Inner matrix dimensions must agree.<br />
&gt;&gt; a*c<br />
ans =<br />
&nbsp;&nbsp;&nbsp;&nbsp; 6<br />
&nbsp;&nbsp;&nbsp; 12<br />
<br />
즉, 가로로 선언된 벡터로는 제대로 곱해지지 않는 것을 알 수 있다.<br />
<br />
<strong>- 덧셈, 뺄셈</strong><br />
<br />
덧셈, 뺄셈에 관여하는 기호와 함수로 여기서 소개될 것은 sum, +, - 정도이다.<br />
위의 a라는 행렬의 정보에서 아래와 같은 명령을 수행하면..<br />
<br />
<em>sum(a)</em><br />
<br />
아래와 같은 결과가 나타난다.<br />
<br />
3 3 3<br />
<br />
즉, 행렬의 열을 모두 합한 결과를 출력해준다. 이것을 이용하면 열로 나타난 자료들의 평균값을 구할 때 유용하게 사용할 수 있을 것이다.<br />
<br />
만약 벡터에서 사용한다면 벡터의 성분들을 그냥 더하게 된다.<br />
<br />
<em>sum(sum(a))</em><br />
<br />
sum(a)의 결과 3 3 3도 일종의 벡터가 되는데 이 sum(a)에다가 다시 sum을 적용한 형태이다. 그리고 그 결과는...<br />
<br />
9<br />
<br />
가 나온다.<br />
<br />
행렬에 일률적으로 얼마만큼의 값을 더하거나 뺄수도 있다.<br />
<br />
<em>Y = a + 2;</em><br />
<br />
라는 문장을 실행시키면 Y에는 아래와 같은 값들이 들어가게 된다.<br />
<br />
3 3 3<br />
4 4 4<br />
<br />
여기서 행렬과 행렬간의 덧/뺄셈이 가능한데<br />
<br />
<em>a - Y;</em><br />
<br />
라는 문장을 실행시키면 결과값으로 아래와 같은 값이 나온다.<br />
<br />
-2 -2 -2<br />
-2 -2 -2<br />
<br />
행렬끼리의 덧/뺄셈은 행렬의 가로 세로 길이가&nbsp;각각 같아야 실행할 수 있다.<br />
<br />
<br />
<strong>- 곱셈, 나눗셈</strong><br />
<br />
여기서의 내용은 일단 아래의 a, b 두 행렬을 사용한다.<br />
<br />
<em>a = [1 2 3]; b = [1 2 3]; %행렬 생성</em><br />
<br />
행렬, 벡터의 곱셈은 2가지 방법을 생각해볼 수 있다.<br />
하나는 대응되는 위치간의 원소들간의 곱으로 위의 덧/뺄셈에서와 계산했던 방식과 유사한 방식이다.<br />
또 다른 방법은&nbsp;행렬 자체의 고유의 계산방식을 생각해볼 수도 있다. - 크기가 같은 벡터의 경우에는 내적과 같은것<br />
<br />
<em>x = a .* b<br />
</em><br />
위는 행렬(벡터)의 원소들간의 곱을 계산한 것이다.<br />
그러므로 결과는 아래와 같이 나온다.<br />
<br />
1 4 9<br />
<br />
.* 라는 연산자가 바로 원소들끼리 곱을 할때 쓰는 것이라는 것을 알 수 있다.<br />
<br />
<em>x = a * b</em><br />
<br />
를 실행하면 결과가 제대로 출력되지 않는 것을 알 수 있다.<br />
<br />
??? Error using ==&gt; mtimes<br />
Inner matrix dimensions must agree.<br />
<br />
* 연산자는 실제 행렬(벡터)간의 보통 곱을 할때 쓰는 연산자로 위에서 선언한 행렬(벡터)의 형태로는 사실 적용이 불가능한 형태이기 때문에 에러가 뜬다. 즉, a나 b 행렬 하나를 transpose 시켜야 결과를 얻을 수 있는 상태이다. 행렬이나 벡터에 transpose를 취하려면 변수명 뒤에 '(작은 따옴표)를 붙인다.<br />
<br />
<em>x = a * b'</em><br />
<br />
14<br />
<br />
과연.. b에 transpose를 시키니 에러없이 제대로된 결과가 출력된다.<br />
<br />
<em>x = a' * b</em><br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp; 1 2 3<br />
&nbsp;&nbsp;&nbsp;&nbsp; 2 4 6<br />
&nbsp;&nbsp;&nbsp;&nbsp; 3 6 9<br />
<br />
물론 a에 transpose를 해도 결과는 나온다. - 물론 서로 다른 결과인 것은 당연하다.<br />
<br />
이와 비슷하게 나눗셈도 적용가능하다.<br />
&nbsp; ./ : 원소간 나눗셈<br />
&nbsp; /&nbsp; : inverse matrix(정방행렬이 아닐 경우 Pseudo inverse matrix)를 곱해줌<br />
<br />
참고로 inverse matrix를 구해주는 함수가 존재하는데 inv(A)와 같은 형태로 사용한다.<br />
<br />
<strong>- 거듭제곱, 제곱근</strong><br />
<br />
우선 행렬을 하나 선언하자.<br />
<br />
<em>a = [ 1 2; 2 1 ];</em><br />
<br />
거듭제곱과 제곱근 또한 어떤 면에서 곱셈, 나눗셈과 비슷하다.<br />
<br />
b = a ^ 2<br />
<br />
위의 문장을 실행하면 b에는 아래와 같은 결과가 들어간다.<br />
<br />
&nbsp;&nbsp;5 4<br />
&nbsp; 4 5<br />
<br />
즉, ^2 를 실행하여 b = a*a 가 되었다.<br />
<br />
위의 곱셈, 나눗셈에서와 같이 .^ 연산자도 존재할 것이라 추측할 수 있다.<br />
<br />
<em>b = a .^ 2</em><br />
<br />
&nbsp;1 4<br />
&nbsp;4 1<br />
<br />
원소들만 제곱을 해준 결과가 b에 저장된다.<br />
<br />
물론 '제곱근'도 구할 수 있을 것이다.<br />
<br />
<em>b&nbsp;= sqrtm(a)</em> (혹은 a ^ (1/2))<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;0.8660 + 0.5000i&nbsp;&nbsp; 0.8660 - 0.5000i<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0.8660 - 0.5000i&nbsp;&nbsp; 0.8660 + 0.5000i<br />
<br />
<em>b = sqrt(a)</em> (혹은 a .^ (1/2))<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; 1.0000&nbsp;&nbsp;&nbsp; 1.4142<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1.4142&nbsp;&nbsp;&nbsp; 1.0000<br />
<br />
<br />
<strong>- 단위행렬, 행렬제거, ones, zeros</strong><br />
<br />
여기는 특별한 설명이 필요없는 부분이므로 간단히 사용법과 결과만 남기도록 한다.<br />
<br />
<em>a = eye(4)</em><br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp; 0<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp; 0<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp;&nbsp;&nbsp;&nbsp; 0<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp; 1<br />
<br />
<br />
<em>a = [1 2 3; 1 1 1; 3 3 3];<br />
a(:,3) = []</em><br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1&nbsp;&nbsp;&nbsp;&nbsp; 2<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp;&nbsp;&nbsp;&nbsp; 1<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3&nbsp;&nbsp;&nbsp;&nbsp; 3<br />
<br />
<em>a = ones(2,1)</em><br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;1<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1<br />
<br />
<em>a = zeros(3)<br />
</em><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0 0 0<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0 0 0<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0 0 0<br />
<br />
<br />
<strong>&nbsp;- 행렬의 변환</strong><br />
<br />
<em>a = [1 2; 3 4]</em><br />
<br />
&nbsp; &gt;&gt; rot90(a,-1)&nbsp;&nbsp; &lt;- 시계방향으로 90도 회전<br />
&nbsp;&nbsp;&nbsp;&nbsp; ans = 3 1<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4 2<br />
&nbsp; &gt;&gt; rot90(a,3)&nbsp;&nbsp;&nbsp; &lt;- 반시계방향으로 270도 회전<br />
&nbsp;&nbsp;&nbsp;&nbsp; ans = 3 1<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4 2<br />
&nbsp; &gt;&gt; flipud(a)&nbsp;&nbsp;&nbsp;&nbsp; &lt;- up,down flip<br />
&nbsp;&nbsp;&nbsp;&nbsp; ans = 3 4<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1 2<br />
&nbsp; &gt;&gt; fliplr(a)&nbsp;&nbsp;&nbsp;&nbsp; &lt;- left,right filp<br />
&nbsp;&nbsp;&nbsp;&nbsp; ans = 2 1<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4 2<br />
&nbsp; &gt;&gt; a'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;- transpose<br />
&nbsp;&nbsp;&nbsp;&nbsp; ans = 1 3<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2 4<br />
&nbsp; &gt;&gt; reshape(a, 1, 4) &lt;- 모양 재설정, a 뒤의 인자들의 곱이 a의 총 원소수와 맞아야 함<br />
&nbsp;&nbsp;&nbsp;&nbsp; ans = 1 2 3 4<br />
&nbsp; &gt;&gt; reshape(a, 4, 1)<br />
&nbsp;&nbsp;&nbsp;&nbsp; ans = 1<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4 			 ]]> 
		</description>
		<category>Matlab &amp; etc</category>

		<comments>http://pandland.egloos.com/3173602#comments</comments>
		<pubDate>Wed, 07 Mar 2007 06:02:56 GMT</pubDate>
		<dc:creator>pandland</dc:creator>
	</item>
</channel>
</rss>
