overflow33の日記

python 機械学習 系の記事を書いて行きたい所存

2020-03-22から1日間の記事一覧

C Matlab python での 2次元配列 比較

2次元配列の書き方 C言語 int x[3][3] = {{0}, {0}}; int i, j; for (i=0; i<3; i++){ for(j=0; j<3; j++){ x[i][j] = i + j; } } for (i=0; i<3; i++){ for(j=0; j<3; j++){ printf("%d ", x[i][j]); } printf("\n"); } output 0 1 2 1 2 3 2 3 4 Matlab x …

C Matlab python での 配列 比較

1次元配列の書き方 C言語 int i; int x[11]={0}; for(i=0; i<=10; i++;){ x[i] = i; } Matlab x = zeros(10) for i = 1: 11 x(i) = i - 1 end python (list) x = [0]*11 for i in range(11): x[i] = i python (numpy) import numpy as np x = np.zeros(11) f…

C Matlab python での if文 比較

if文(条件分岐)の書き方 C言語 int x,y; x = 0; if (x == 0){ y = x + 1; }else if(x == 1){ y = x - 1; }else{ y = x; } Matlab x = 0; if x == 0 y = x + 1; else if x == 1 y = x - 1; else y = x; end python x = 0 if x == 0: y = x + 1 elif x == 1: y…