Filter löschen
Filter löschen

How to save genetaed figures after each loop and put all generated areas in one matrix?

1 Ansicht (letzte 30 Tage)
Hello everyone,
I downloaded a code from MATLAB cummnity to perform my peak deconvolution. I have muliptle txt datasets. I need to get the curve and area under the peaks after each iteration.Then I need to plot the figures and put all generated areas under each peak. in one materix. But when I ran this code, it only gves me the last iteration result. I am wondering if anyone could help me with. I have uploaded all the dataset and code in google drive. Please find them in the following link.
Thank you,
MCC
  3 Kommentare
MCC
MCC am 26 Mär. 2020
Yes, since I have uploaded 5 TXT files, I just need to get the plotting of each TXT file. But when I ran this code, I can only get the last TXT file results. The previous four TXT file results are overlapped during the loop. I think change ploter. m function. For example, add a loop inside it. However, it gives me errors each time.
MCC
MCC am 26 Mär. 2020
It seems like the fitV.m function needs to be changed between line 138 and line 169 to get the area for each loop. The function plotter.m needs to be changed to get the curve for each loop. Thanks.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Maxim
Maxim am 26 Mär. 2020
this uses the 'lsqcurvefit' to fit the functions.
As far as I know there is no simple way to get the fitting constants at each iteration as an output. Read the function description, maybe I've missed something.
You can artificially do it by changing the maximum number of iterations, running the script and increasing this number each time.
You can do it by changing the number after 'MaxIter', on line 44 in fitV.m.
  1 Kommentar
Ameer Hamza
Ameer Hamza am 26 Mär. 2020
Allthough I haven't seen the OP's code but if the issue is to extract values at each iteration of lsqcurvefit can you can specify OutputFcn as an option to the optimizer https://www.mathworks.com/help/optim/ug/lsqcurvefit.html#buuhcjo-options. This function is called by the optimizer after each iteration. For example, check this: https://www.mathworks.com/matlabcentral/answers/510713-is-it-possible-to-store-the-intermediate-values-of-fmincon

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by