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

2 ビュー (過去 30 日間)
MCC
MCC 2020 年 3 月 26 日
コメント済み: MCC 2020 年 3 月 26 日
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 件のコメント
MCC
MCC 2020 年 3 月 26 日
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 2020 年 3 月 26 日
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.

サインインしてコメントする。

回答 (1 件)

Maxim
Maxim 2020 年 3 月 26 日
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 件のコメント
Ameer Hamza
Ameer Hamza 2020 年 3 月 26 日
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

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by