Read multiple files and store fitting parameters & graphs
1 回表示 (過去 30 日間)
古いコメントを表示
I have a function that reads from an input file (floating point numbers, only) columns (A, B, C, D, E, F, G, H, I) perform some mathematical operations and plot some fittings.
Since I have multiple input files named as: res1, res8, ..., resn, attention not in sequencial order (meaning not having res2, for example) how should I do for my script read all those input files and for each run/analysis create an output file results1, results8 ... etc, with fitting results and plots?
Any help would be much appreciated.
4 件のコメント
Bob Thompson
2019 年 2 月 12 日
You're only getting one set of outputs because you're only looking at mydata{k}, where k is numfiles (the last one). If you want to perform the operation for all of the files, move them all inside the loop, including the output.
回答 (2 件)
Bob Thompson
2019 年 2 月 12 日
function [results] = test(A,B,C,D,E,F,G,H,time)
numfiles = 2;
mydata = cell(1, numfiles);
for k = 1:numfiles
myfilename = sprintf('Res%d.txt', k);
mydata{k} = importdata(myfilename);
A = mydata{k}(:,1);
B = mydata{k}(:,2);
C = mydata{k}(:,3);
D = mydata{k}(:,4);
E = mydata{k}(:,5);
F = mydata{k}(:,6);
G = mydata{k}(:,7);
H = mydata{k}(:,8);
time = mydata{k}(:,9);
ABsub = E - E(1);
BAsub = G - G(1);
ref = A(1) + C(1);
AA = A/ref;
BB = B/ref;
AB = ABsub/ref;
BA = BAsub/ref;
% Insert new database creation here
% Insert output command here
end
0 件のコメント
Angelo Figueiredo
2019 年 2 月 13 日
8 件のコメント
Bob Thompson
2019 年 2 月 13 日
Mmm, I forgot this part. Put brackets around your new structure field definitions.
[default.ex] = 3.2;
[default.pA] = ...
参考
カテゴリ
Help Center および File Exchange で Get Started with Curve Fitting Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!