Matlab関数

1022 ワード

Matlabではinlineを使用してローカル関数を作成します.これにより、関数を個別のローカルファイルに保存する必要がなくなります.inlineの式はinline関数をネストすることができず、その戻り値は1つしかありません.
clear
clc
%% just one parameter, the next two is equivalent
mySigmoid = inline('1/(1+exp(-z))');
mySigmoid(0)
mySigmoid = inline('1/(1+exp(-z))','z');
mySigmoid(0)
%% when there is more than one arguments, it's sorted by alphabetical order default
% therefore the following two is equivalent and differnt from the last one
m = inline('a * x * a + b * x + c');
m(1, 2, 3, 20)
m = inline('a * x * a + b * x + c', 'a', 'b','c','x');
m(1, 2, 3, 20)
f = inline('a * x * a + b * x + c', 'a', 'b','x','c');
f(1, 2, 3, 20)

Fevalの使い方は、functionnameが関数ハンドルまたは関数名であってもよいfeval('functionname',parameter)です.
Feval('exp',1)とfeval(@exp,1)
permute:多次元マトリクス回転.
norm:パターンを取ります.
contour:関数の等高線を描く
contour(x,y,z):xとyは平面座標を指定し、xとyは回転されるか、ソートされるべきである.