Mathematica Asked on June 5, 2021
I want to print the messages or warning message tags for NonlinearModelFit
when batch fitting data. For example, I will import and fit my data with something like
Table[
MyData = Import[DataSetList[[i]]];
MyFit = NonlinearModelFit[MyData, MyFitFunction[a, b, c, x], {a, b, c}, x];
MyFitMessageTags = (* ??? *);
{i, MyFit, MyFitMessageTags},
{i, 1, NumberOfDatasets}
]
The idea being that I can easily filter out fit results which have a message or specific message tag. I’m really struggling to find what I want. I’ve tried Messages[NonlinearModelFit]
as I read this should output the messages associated to NonlinearModelFit
from the previous session, but I don’t see any change in the messages at all — possibly because it is inside a table so that only counts as one session?I’ve also tried EvaluationData
, but again I don’t get what I expect here either.
Check
could be an option but it seems that if you get any message then you don’t get the output from the function. This is undesirable as sometimes Mathematica will issue a warning, even though the output is good. For example if the function has decided a better method should be used and switches from the default.
This should be very easy, and it probably is but I’m looking in the wrong place, but so far I am struggling!
Okay, one very roundabout way could be to encapsulate the fit in a Check
and check for a null
:
MyFitCheck =
Check[
NonlinearModelFit[MyData, MyFitFunction[a, b, c, x], {a, b, c}, x];,
"FIT WARNING"
];
FitWarningTag = If[MyFitCheck == Null, "GOOD FIT -- NO WARNING", "FIT WARNING"];
It works, but it would be better to output the specific tag.
Answered by Q.P. on June 5, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP