MATLAB

フォルダ内のファイルにアクセス(再掲)

[filename, pathname] =uigetfile('*.csv'); fnlen = length(filename); % get directory info dirinfo = dir(pathname); lenDir = length(dirinfo); fileNames = []; for i=3:1:lenDir readFileName = [pathname, dirinfo(i).name]; fileNames = [fileNames…

Struct access

a: structだとすると、nameというfieldを持っていた場合には a(1).name のようにアクセスする。 a.name(1) ではない。

chi-squared distribution

close all; clear all; x = 0:0.2:100; y = chi2pdf(x,38); figure; plot(x,y) ylabel('Probability density'); xlabel('Chi-squared value'); % calculate chi-squared value over specific probability % under specified degree of freedom X_05 = chi2in…

Colormap

https://jp.mathworks.com/help/matlab/creating_plots/change-colorbar-width.html

Colormap

colormap = jet(14); plot(x, y, 'o-', 'Color', colormap(i,:));Lineを適切に変える方法について、今後調べる。忘れやすい、Line propertiesの設定 https://jp.mathworks.com/help/matlab/ref/plot.html

labels on x, y axis

set(gca, 'XTick', -75:25:50) set(gca, 'XTickLabel', -75:25:50) set(gca, 'YTick', -1.0:0.50:1.0) set(gca, 'YTickLabel', -1.0:0.5:1.0) axis([-80,55, -1.2, 1.2]);

an easy way to select a file

Matlab 備忘録fname=uigetfile('*.txt');で,user interfaceから読み出すべきファイルを選択できるそのほかの情報は下記. http://www.eecs.umich.edu/dco/faq/matlab-6.5/help/techdoc/ref/uigetfile.html追記 on 2020/3/26 [filename, pathname] =uigetfil…

ガウス包絡線を描く

gauspulsを使えばよい.そのほかの曲線に関しては, http://infoshako.sk.tsukuba.ac.jp/ShakoDoc/MATLAB5/jhelp/toolbox/signal/gauspuls.html などを参照. また,ヒルベルト変換による,Envelope描画は次のページに記載あり. http://www.onosokki.co.jp/…

¥マークをfprintfするには

'\\' と\マークを二つ書く.たとえば,fid = fopen('List.csv','W'); List = []; for i=1:1:48 List = ['p1', ',', 'bmp', '\\', filename_list(i,:), ',', state_list(i)]; fprintf(fid, List); fprintf(fid, '\n'); %%colの数で改行 end fclose(fid);

ファイル入出力

いまさらながら、ファイル入出力の雛形の覚書。 % data (N x M Matrix)の中身をテキストに書き出す fid = fopen('data.txt','W'); [row col] = size(data);for j=1:1:row for i=1:1:col cstr = int2str(concrete_num(i+(j-1)*col)); cstr = [cstr, ',']; fpr…

各Figureをフレームとして,ムービーを書き出す方法

今日の成果. %%%%% mov = avifile('test.avi'); mov.Quality = 75; %% 圧縮しないなら意味なし mov.compression = 'none'; %% コーデックを指定. h = figure(1); F = getframe(h); mov = addframe(mov,F);%%%%% ....mov = close(mov); %%%%%また,figureを…