Check for missing argument or incorrect argument data type in call to function 'abs'.

4 Ansichten (letzte 30 Tage)
I'm building code for getting IAE and ITAE values from a controller project.
Using a function already tested by me in other programs it returns this error message:
Check for missing argument or incorrect argument data type in call to function 'abs'.
The part of the code that is giving a problem is below:
res = sim('RTS.slx');
erroa= abs(1-res.control);
erroat = abs(dt *(1-res.control));
IAE= trapz(res.tempo, erroa);
ITAE= trapz(res.tempo, erroat);

Antworten (2)

Paul
Paul am 31 Okt. 2021
I doubt that res.control is a numeric array. Depending what how the signal "control" is formed in the simulation RTS, you'll probably need to use addittional qualfiers to get to the actual data in res.control. For example, if control is a timeseries output from a To Workspace block, you'd need
erroa = abs(1 - res.control.Data)
  11 Kommentare
Paul
Paul am 31 Okt. 2021
Bearbeitet: Paul am 1 Nov. 2021
Hmm. Should work just fine:
res.control = timeseries(rand(84,3000),0:83);
res.control
timeseries Common Properties: Name: 'unnamed' Time: [84x1 double] TimeInfo: tsdata.timemetadata Data: [84x3000 double] DataInfo: tsdata.datametadata
erroa = abs(1 - res.control.Data);
iae = trapz(res.control.Time,erroa);
size(iae)
ans = 1×2
1 3000
Of course, res is just a regular structure here, not a Simulink.SimulationOutput object, but that shouldn't matter.
Do you see this after the which() command?
which trapz -all
/MATLAB/toolbox/matlab/datafun/trapz.m /MATLAB/toolbox/parallel/gpu/@gpuArray/trapz.m % Shadowed gpuArray method /MATLAB/toolbox/parallel/parallel/@codistributed/trapz.m % Shadowed codistributed method
Image Analyst
Image Analyst am 1 Nov. 2021
Try operating on one column of data at a time
columnNumber = 15; % whatever...
erroa = 1 - res.control.Data(:, columnNumber);

Melden Sie sich an, um zu kommentieren.


Image Analyst
Image Analyst am 31 Okt. 2021
Bearbeitet: Image Analyst am 31 Okt. 2021
res does not have a field, property, or method called control. What does this show:
res = sim('RTS.slx') % Don't use a semicolon
fieldnames(res)
properties(res)
methods(res)
v = res.control
whos v
Dont' use semicolons. If any throw errors, just comment them out and tell us what the rest display in the command window.

Community Treasure Hunt

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

Start Hunting!

Translated by