MATLABのコードって忘れやすい・・・

プログラムのコマンドなんて忘れやすいもの・・・いっそのことネット上に保存してシェアしましょう!!
It's easy to forget command for MATLAB in programming.... Let's share small help for Matlab code with you on the web!!



ラベル matlab の投稿を表示しています。 すべての投稿を表示
ラベル matlab の投稿を表示しています。 すべての投稿を表示

2010年9月30日木曜日

棒グラフ色々 Several bar graphs

Y = round(rand(5,3)*10);
subplot(2,2,1)
bar(Y,'grouped')
title 'Group'
subplot(2,2,2)
bar(Y,'stacked')
title 'Stack'
subplot(2,2,3)
barh(Y,'stacked')
title 'Stack'
subplot(2,2,4)
bar(Y,1.5)
title 'Width = 1.5'

2010年9月21日火曜日

matrixの上下の反転 Flip a matrix from up to bottom

使えそうなコードを見つけた・・・flipud
matrixをup & downと反転させる場合に使えそう。

function y = flipud(x)
%FLIPUD Flip matrix in up/down direction.
% FLIPUD(X) returns X with columns preserved and rows flipped
% in the up/down direction. For example,
%
% X = 1 4 becomes 3 6
% 2 5 2 5
% 3 6 1 4
%
% Class support for input X:
% float: double, single
%
% See also FLIPLR, ROT90, FLIPDIM.

% Copyright 1984-2004 The MathWorks, Inc.
% $Revision: 5.9.4.3 $ $Date: 2004/07/05 17:01:15 $

if ndims(x)~=2
error('MATLAB:flipud:SizeX', 'X must be a 2-D matrix.');
end
y = x(end:-1:1,:);

errorbar etc....

Matlab Centralを見ると、errorbarに関するコードが他にもこんなにあった。

http://www.mathworks.com/matlabcentral/fileexchange/27387-create-healthy-looking-error-bars

http://www.mathworks.com/matlabcentral/fileexchange/10803-barweb-bargraph-with-error-bars

http://www.mathworks.com/matlabcentral/fileexchange/27494

ってなわけで、これを試してみるべし。