Filter löschen
Filter löschen

how to get fit coefficients and the file name ?

30 Ansichten (letzte 30 Tage)
dareen
dareen am 24 Jun. 2024 um 12:45
Kommentiert: dareen am 27 Jun. 2024 um 14:49
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 Kommentare
dareen
dareen am 24 Jun. 2024 um 12:49
Bearbeitet: dareen am 24 Jun. 2024 um 12:50
it seems i will do this maually for around 50 files this time and i know it is totally implementable ,
John D'Errico
John D'Errico am 24 Jun. 2024 um 13:46
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.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Steven Lord
Steven Lord am 24 Jun. 2024 um 14:10
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.
  2 Kommentare
dareen
dareen am 27 Jun. 2024 um 14:49
thank you exactly what i needed a set of tools and resourses to study
dareen
dareen am 27 Jun. 2024 um 14:49
took me a while to read and apply but worked well

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Linear and Nonlinear Regression finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by