フォルダ内のファイルにアクセス(再掲)
[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; dirinfo(i).name]; %filenameのリストを作成
%行いたい処理
例:
numData = readtable(readFileName, opts);
end
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 = chi2inv(0.95,38)
X_01 = chi2inv(0.99,38)
X_001 = chi2inv(0.999,38)
show = ['Chi-squared 0.05: ', num2str(X_05)];
text(60, 0.03, show);
show = ['Chi-squared 0.01: ', num2str(X_01)];
text(60, 0.025, show);
show = ['Chi-squared 0.001: ', num2str(X_001)];
text(60, 0.020, show);
title('Chi-squared distribution dof=38')
UnicodeDecodeError
UnicodeDecodeError: 'ascii' codecで悩まされる。
Version 1. 83.4では問題が起きなかったが、1.85.4ではUnicodeDecodeErrorが生じる。
バグフィックスをしたかったが、十分な時間が足らないため、1.83.4にバージョンを落として、ASCIIコード問題を回避。時間があるときに、きちんと対策を考えたい。
Colormap
colormap = jet(14);
plot(x, y, 'o-', 'Color', colormap(i,:));
Lineを適切に変える方法について、今後調べる。
忘れやすい、Line propertiesの設定
https://jp.mathworks.com/help/matlab/ref/plot.html