2019년 10월 29일 화요일

matlab file load, save

1. what is mat file
MAT-files are binary MATLAB® files that store workspace variables.
matlab 에서 사용하는 binary 파일이다. 세부 형식은 matlab 고유의 방식이지 않을까

Starting with MAT-file Version 4, there are several subsequent versions of MAT-files that support an increasing set of features. MATLAB releases R2006b and later all support all MAT-file versions.
지금까자 여러 버전의 mat 파일이 존재하며 R2006b 부터는 모든 mat 파일이 지원된다고 하니 이후에는 업데이트 된 것이 없다고 봐야 하는 것인가.


2. load function
load('filename') 일 때는 filename 에 확장자가 명시되어 있으며 확장자를 따른다. mat 형식이나 ascii 형식이 있을 수 있다. 그래서 mat 이라고 적혀있지 않으면 ascii 형식으로 load 한다.
그래서 load('filename', '-mat') 으로 하면 확장자에 구애하지 않고 mat 파일을 load 한다.

3. save function
save('filename', '-struct', structName) 일 때 structName 구조체의 값들을 filename 에 개별 변수로 저장한다.
이 때 이렇게 저장한 filename 을 tmp_name = load('filename', 'mat') 으로 load 하면 tmp_name 이 structName 의 모든 변수를 가진 구조체가 된다.

2019년 7월 21일 일요일

MATLAB

단축키
    - 여러줄 주석 처리 ctrl + r
    - 여러줄 주석 해제 ctrl + t

2019년 7월 20일 토요일

Visual Studio Code - Python

1. python 실행파일 경로 연결할 때
    - settings.json 에서 경로를 지정해 준다.
{
"python.pythonPath": "C:\\Users\\user\\AppData\\Local\\Programs\\Python\\Python36\\python.exe",
"scm.alwaysShowActions": true,
"window.zoomLevel": -1,
"python.jediEnabled": false
}

2. Argument 줄 때
    - launch.json 에서 아래와 같이 args 안에 순서대로 입력

"configurations": [
{
"name": "Python: Current File (Integrated Terminal)",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"args": [
"-s",
"00003521"
],
"cwd": "${fileDirname}"
},

3. file explorer 부를 때
    - ctrl + shift + E

4. 모든 커맨드를 실행할 때
    - ctrl + shift + p
    - show all command 라고 부른다.

5. 특정 파일을 부를 때
    - show all command 한 다음 launch.json 이나 settings.json 을 친다.

6. debug 진행
---
A debug toolbar appears along the top with the following commands from left to right: continue (F5), step over (F10), step into (F11), step out (Shift+F11), restart (Ctrl+Shift+F5), and stop (Shift+F5).
---
 
7. python version check
python -V

8. pyhton computer check
$ python-32 -c 'import sys;print("%x" % sys.maxsize, sys.maxsize > 2**32)'
('7fffffff', False)
$ python-64 -c 'import sys;print("%x" % sys.maxsize, sys.maxsize > 2**32)'
('7fffffffffffffff', True)

9. turtle 로 그림 그리기
    1) turtle 로 라인 그리기
    2) turtle 의 screen size 조정하기
    3) turtle 의 origin 설정하기
    4) pen  color 설정하기
    5) svg 이미지로 저장하기
    6) svg 이미지를 png 로 변환하기 https://pypi.org/project/svglib/













2019년 5월 19일 일요일

MFC C++ Note

특정 Cotrol 의 색을 변경하고 싶을 때
1. Dialog 의 Window Message 중 WM_CTLCOLOR 을 Enable 한다.
2. OnCtlColor 함수가 자동으로 생긴다.
3. OnCtlColor 함수는 Control이 보여주는 이벤트가 생길 때(Test 를 쓰거나 등) 불리게 된다. (참조: Link)
4. OnCtlColor 함수를 적어준다. (참조: Link)
5. 내가 원하는 특정 Control 만을 변경시키고 싶으면 각 case 안 해당 코드에 if 를 넣어주면 된다.



No 4
HBRUSH Cxxxxxx::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialogEx::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO:  Change any attributes of the DC here
switch(nCtlColor){
case CTLCOLOR_DLG:   /// 다이얼로그 배경색을 white로.
{        return (HBRUSH)GetStockObject(WHITE_BRUSH);
        break;
}
case CTLCOLOR_BTN :    // 버튼의 배경색을 투명으로...
{
        pDC->SetBkMode(TRANSPARENT);
                  return (HBRUSH)::GetStockObject(NULL_BRUSH);
        }
         case CTLCOLOR_STATIC:
        {
               pDC->SetTextColor(RGB(0,255,255));  // static text 글자색 변경
                 pDC->SetBkMode(TRANSPARENT);   // static text 배경색 투명
                 return (HBRUSH)::GetStockObject(NULL_BRUSH);
        }
}
// TODO:  Return a different brush if the default is not desired
return hbr;
}

2019년 4월 22일 월요일

Matlab

   
CSV 로 출력할 때
simulation_results = [FP_2_x(h,i), FP_2_y(h,i), R_2(1,i), R_2(2,i)-Da];
dlmwrite('C:\simulaton_results.csv', simulation_results, '-append');

dlmwrite('C:\FP_2_x__h_i.csv', FP_2_x(h,i));

2019년 3월 1일 금요일

Visual Studio 2017 노트

목적: Visual Studio 2017(이하 vs17) 로 opencv 를 사용하고 싶다.

1. opencv library를 찾아야 한다.
    1) 어떤 opencv version 을 사용할 것인지 정한다  
        - 기본 기능이 동작하는지 확인하는 것이므로 아무 version 상관없다.
        - vs17을 사용해야 하므로 vs17 지원하는 version이 필요하다. 
             + vs17 은 vc15(Visual Studio Compiler 15?) 를 써야 한다.
        -> 3.4.3 은 vs17 지원하므로 사용하기로 했다.
    2) opencv를 빌드 한다.
        - 배포되는 opencv 들은 필요한 binary 가 모두 빌드된 것이 아니라 추가된 기능한 빌드된 것이기 때문에 직접 빌드를 해야한다.
        - x64 컴퓨터라고 x64 실행하려고 하면 안된다 왜냐하면 dll 들이 거의 다 x86 이기 때문?
        - CMake/vs17 로 빌드하면 vs17 프로젝트 generate 가능하며 이 프로젝트로 빌드하면 필요한 dll 들을 생성할 수 있다. 이것들로 프로그램 실행하면 된다.
         - cmake 사용 방법
             https://stackoverflow.com/questions/43786856/how-can-i-install-configure-opencv3-2-0-with-c-visual-studio-2017
2. 빌드를 한 후에는 링크에 모든 lib 파일이름을 적어준다.

목적: Visual Studio Debug

debug 시작해도 관련 dll 을 로딩하는데 시간이 걸릴 수 있다.

2019년 2월 12일 화요일