Page 1 of 1

Custom simulation function (Error: Not enought input arguments)

Posted: Tue Apr 01, 2025 8:02 am
by kulrich

Hello,

I am trying to figure out how to use custom simulation functions for coupled parameters. Therefore, I am executing an example from Easyspin Acadamy 2020 (code provided below). However, when starting the fitting procedure in the GUI the fitting does not beginand the following log message appears.

"Running optimization algorithm with 1 active parameters...
Simulation function error:
Not enough input arguments."

Does anyone know which part of the code this refers to or how to fix this?

Thanks in advance!

I am running the code on Matlab R2024a with Easyspin 6.0.6

Code: Select all

clear, clf, clc

Sys.g=2;
Sys.Nucs = '1H, 1H, 1H';
Sys.n = [2 3 2];
Sys.A = [20; 30; 50];
Sys.lwpp =  [0 0.1];

Exp.mwFreq = 9.5;
Exp.Range = [330 350];


[B,spc_exp] = garlic(Sys,Exp);
spc_exp = addnoise(spc_exp,100,'f');
plot(B,spc_exp);

Sys.myA = 20;
Vary.myA = 5;

esfit(spc_exp,@mysimfun,{Sys, Exp}, {Vary});

function spc= mysimfun(Sys,Exp,Opt)
    Sys.A = Sys.myA*[1, 1.5, 2.5];
    spc = garlic(Sys,Exp,Opt);
end

Re: Custom simulation function (Error: Not enought input arguments)

Posted: Tue Apr 01, 2025 11:57 pm
by katarkon

You try to use diffrenent parameter's set for custom simulation function and esfit(). I mean Opt parameter.


Re: Custom simulation function (Error: Not enought input arguments)

Posted: Wed Apr 09, 2025 4:38 am
by kulrich

Thank you!