it seems i will do this maually for around 50 files this time and i know it is totally implementable ,
how to get fit coefficients and the file name ?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
there is a particular feature that i needed a couple of times now but i am failing at finding something to implement it
inductor_files = {
'2_2.csv', '2_5_long.csv', '8_8.csv', '11_9.csv', '14_2.csv', ...
'24_8.csv', '27_0.csv', '29_3.csv', '31_5.csv', '33_2.csv', ...
'33_7.csv', '34_3.csv', '34_8.csv', '36_6.csv', '37_7.csv', ...
'42_2.csv', '44_3.csv', '49_4.csv'
};
% Loop through each inductor file
for i = 1:length(inductor_files)
% Read the data from the CSV file
data = readmatrix(inductor_files{i});
% Plot the data
figure;
% plot(data(:,4), data(:,5));
cftool(data(:,10), data(:,11));
end
if you look at the following code for now what it simply does is use cftool to graph 18 graphs i keep doing the fit on them manually through the cftool window and same for extracting the coffecients ,
the more files i have the more time consuming this is , if i want to write something along the following lines
cftool(data(:,10), data(:,11)) fit (sum of sine ,order 1 , for all )
so when the cftool opens i have the default fiting here be sum of sine
second if i want the coffecients that define amplitude of the sin genearted to be saved in order of each run so i know what file are they extracted in how can i access the coffecient of intrest and save the data it carries
2 commentaires
John D'Errico
le 24 Juin 2024
Why do you think you need to use cftool? You don't. cftool is merely a gui interface for the curve fitting toolbox. But you don't need the gui interface at all. In fact, you really don't want it, since you are doing the same fits for each set of data. Instead, learn how to use tools like fittype and fit.
You can still plot the fit if you want, since plot works on what fit returns. And since fit returns an object that contains the fitted model itself, that gives you the coefficients you need.
Réponse acceptée
Steven Lord
le 24 Juin 2024
You can perform the fitting once in the Curve Fitting app then generate MATLAB code from that interactive fit that you can later run with a new data set to fit it in the same manner. Then you could evaluate the fits at specific points.
Alternately you could follow the workflow given on this documentation page to programmatically fit your data without having to open the Curve Fitting app and interactively perform the fit.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Interpolation dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!