'MATLAB'에 해당되는 글 3건

  1. install matlab on OSX 2007.12.05
  2. mlUnit: matlab용 unit test suite 2007.11.15
  3. Numpy 2007.10.16

install matlab on OSX

from 카테고리 없음 2007. 12. 5. 02:28

Before you run the MathWorks Installer:

  • Make sure you have your License File. Every installation requires a License File. You need to copy and paste your licensing information into the License File dialog box during the installation process. For more information about License Files, see Product Licensing.
  • Installing X11 for Mac OS X before installing MATLAB is recommended. You can either install X11 from Optional Installs on the Installer Disc that came with your Mac or download it from the Apple Web site. (For Mac OS 10.4, you must install X11 from the Tiger DVD; it is not available for download at the Apple Web site. Be sure to use the appropriate Tiger DVD for your platform.) For information about other requirements, see System Requirements.

기본적으로 맥은 Unix였던거였다. 까먹지 말도록
,

새로 맡은 프로젝트 도중, 매틀랩을 쓸일이 생겼다. 제법 큰 패키지 이고, 나중에 공개될 수 있기 때문에 유닛테스트를 통해 안정성을 확보하고, TDD를 이용해 빠른 개발을 하는 것이 목적이었다. 막상 매틀랩에서의 유닛 테스트를 검색해보니 쓸만한 것은 mlUnit과 mUnit이라 서드 파티 툴을 발견했다. 둘다 GPL라이센스이기 때문에 그냥 쓸수 있다. 개인적으로 참고하려고 스크랩 해둔다.

출처: mlUnit: MATLAB Unit Testing

----------------------------------------------

mlUnit에 대해서


mlUnit 은 MATLAB.m language를 위한 유닛테스트 프레임웍이다, xUnit계열의 패턴을 이용한다. 풀어서 얘기하면 mlUnit은 MATLAB .m language 버젼의 JUnit이다.

mlUnit과 모든 과련 파일들은 GNU General Public License (GPL)Free Software Foundation

이 퍼블리싱한다.


설치

Download 하고 설치한 디렉토리를 MATLAB 경로에 추가:

addpath('$MLUNIT\src');
addpath('$MLUNIT\test');

$MLUNIT은 mlUnit가 설치된 디렉토리로 바꾸어 넣는다.

어떻게 테스트할까?

built-in sin 함수에 대한 테스트 예제다:

  1. @test_sin라는 새로운 디렉토리를 만들고, 이동:
    mkdir @test_sin
    cd @test_sin
    
  2. 새로운 .m file로 test_sin.m을 만든다 (the constructor):
    edit test_sin.m
    
  3. 테스트 케이스 test_sin는 test_case클래스로 부터 상속받는다, 그러기 위해 test_sin.m에 다음 명령어를 추가한다:
    function self = test_sin(name)
    
    tc = test_case(name);
    self = class(struct([]), 'test_sin', tc);
    
  4. 첫번째 테스트는 sin(0) = 0임을 확인하는 것이다. 새로운 test_null.m을 생성하고 다음을 입력한후 저장한다:
    function self = test_null(self)
    
    assert_equals(0, sin(0));
    
  5. 테스트를 실행하기 위해서 다음과 같이 입력한다:
    cd ..
    runner = text_test_runner(1, 1);
    loader = test_loader;
    run(runner, load_tests_from_test_case(loader, 'test_sin'));
    
  6. 참간단한 결과가 아닌가:
    .
    ----------------------------------------------------------------------
    Ran 1 test in 0.010s
    
    OK
    
  7. 다른 테스트셋 추가, e.g. test_sin_cos.m, 코사인과 사인값을 체크하는 테스트:
    function self = test_sin_cos(self)
    
    assert_equals(cos(0), sin(pi/2));
    
  8. 테스트 돌리기:
    run(runner, load_tests_from_test_case(loader, 'test_sin'));
    
  9. 다음과 같은 결과가 나온다:
    .
    ----------------------------------------------------------------------
    Ran 2 tests in 0.010s
    
    OK
    
  10. text_test_runner에 다른 매개변수를 넣어보자:
    runner = text_test_runner(1, 2);
    run(runner, load_tests_from_test_case(loader, 'test_sin'));</pre>
    
    
  11. 이번에 약간 다른 방식으로 테스트 결과가 출력된다:
    test_null(test_sin) ... OK
    test_sin_cos(test_sin) ... OK
    
    ----------------------------------------------------------------------
    Ran 2 tests in 0.020s
    
    OK
    
  12. 테스트 클래스에대해 좀더 알고 싶으면, e.g.:
    help text_test_runner
    
    

mlUnit GUI버젼

일일히 run(...)처넣는 일을 피하고 싶으면, GUI를 이용하면 깔끔하다. 사실 이것 때문에 여러가지 unittest중에 mlunit을 선택했다.
run(gui_test_runner, 'test_sin')
,

Numpy

from 카테고리 없음 2007. 10. 16. 10:10
NumPy

파이썬에서 과학 계산을 위해 필요한 기본적인 패키지를 NumPy(넘피)라고 하다. 이패키지는 다음의 기능을 가지고 있다.

-강력한 N차원 배열 객체
-새련된 함수(^^)
-기본적인 선형 대수 함수
-기본적인 푸리에변환 함수
-정교한 난수 발생기능
-포트란과의 통합을 위한 툴

기존의 Numarray/Numeric 패키지와도 변환과정을 거치면 호환성을 가지고 있다.
메인 개발자인 Travis Oliphant가 쓴 책을 사는것도 방법이지만, 무료 문서들을 scipy 웹사이트에서 참조하는 것도 방법이다.

참고링크:
매트랩사용자를 위한 넘피소개
예제로보는 넘피명령어
싸이피/넘피 쿡북


,