Error in using 'frestimate' for MIMO system
Show older comments
I am using frestimate for finding frequency response function of a non-linear system which has multiple inputs and multiple outputs,

Picture above shows the simulink model, I have selected 1 input (out of 2) and 1 output (output), I get following error after using
[sysest,simout] = frestimate(mdl,getlinio(mdl),in);
Error using frestimate>LocalRunSimulation (line 1165)
State derivatives returned by S-function 'System_Model' in 'Non_Linear_Model_FRF/Validation
Setup/S-Function' during flag=1 call must be a real vector of length 13
Error in frestimate (line 255)
[simout{ctexp},err] = LocalRunSimulation(parammgr,SimulationPackage,ctexp); -
Show complete stack trace
Answers (1)
Walter Roberson
on 26 Jun 2020
0 votes
Your S function Validation Setup has 13 outputs. The model derivatives for it must return 13 values, one for each of those 13 outputs.
It looks to me as if your S function is probably a Level 1 S function that is being passed u and flag and is expected to detect the various flag states to decide what it is doing.
4 Comments
Siddhesh Rane
on 26 Jun 2020
Walter Roberson
on 26 Jun 2020
In calculationg xdot(9) and xdot(11) you have some sqrt() of subtractions. Those subtractions can come out negative, leading to sqrt() of negative numbers, leading to non-real results.
Siddhesh Rane
on 26 Jun 2020
Walter Roberson
on 26 Jun 2020
After the assignment to sys, add in lines:
assert(length(sys) == 13, 'derivatives are wrong length')
assert(all(isfinite(sys)), 'derivatives are not all finite')
assert(all(imag(sys) == 0), 'derivatives are not all real')
Categories
Find more on General Applications in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!