Check for missing argument or incorrect argument data type in call to function 'abs'.
이전 댓글 표시
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);
답변 (2개)
Paul
2021년 10월 31일
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
Lucas Antonelo
2021년 10월 31일
Paul
2021년 10월 31일
Now there is the same issue with res.tempo. You need additional qualification to get to the data in res.tempo that you are trying to access.
Lucas Antonelo
2021년 10월 31일
Paul
2021년 10월 31일
More information needed. Type these two lines in the command window and copy the results here
res.control
res.tempo
Lucas Antonelo
2021년 10월 31일
Image Analyst
2021년 10월 31일
It seem you can't subtract a time series from 1. Try to convert it to a double somehow. Maybe you meant (1-res.control.Time) or something?
Lucas Antonelo
2021년 10월 31일
res.tempo is a timeseries as is res.control.
res.tempo.Time; % acceses the time vector
res.tempo.Data; % accesses the data values
In both cases, the Data is an 84 x 3000 array, one row per time point. It's likely, but not guaranteed, that res.tempo.Time and res.control.Time are equal to each other. I think you could do
erroa = 1 - res.control.Data;
but then erroa will be a timeseries that you can't input directly to trapz.
Maybe you you want to do something like this?
erroa = abs(1 - res.control.Data); % 84 x 3000 array
ITAE = trapz(res.control.Time,erroa) ; % should be a 1 x 3000 array, integrating each colum wrt time
Lucas Antonelo
2021년 10월 31일
Hmm. Should work just fine:
res.control = timeseries(rand(84,3000),0:83);
res.control
erroa = abs(1 - res.control.Data);
iae = trapz(res.control.Time,erroa);
size(iae)
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
Image Analyst
2021년 11월 1일
Try operating on one column of data at a time
columnNumber = 15; % whatever...
erroa = 1 - res.control.Data(:, columnNumber);
Image Analyst
2021년 10월 31일
편집: Image Analyst
2021년 10월 31일
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.
카테고리
도움말 센터 및 File Exchange에서 Numerical Integration and Differentiation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!