필터 지우기
필터 지우기

Definition of Integral Square Error via matlab (ISE)

조회 수: 44 (최근 30일)
Rakesh Jain
Rakesh Jain 2017년 8월 28일
편집: John D'Errico 2022년 11월 24일
I have to find integral square error, where error is defined below. I For the purpose of defining ISE, I have taken t= 0:0.1:100, meaning that step response is sampled every 0.1 second and its difference from the reference value of 1 is found. Is the below given definition (in matlab code) of ISE correct or do we have to multiply the ise obtained from the below code by 0.1 since the width of rectangle is 0.1 whose length is the error.
[y t]=step(clProp,0:0.1:100)
for i = 1:101
error(i) =1 - y(i);
end
error1=error*error';
ise=abs(sum(error1))

채택된 답변

John D'Errico
John D'Errico 2017년 8월 28일
Many points to make here. First, DON'T use error as a variable name. In general, it is never a good idea to use variable names that are the same as existing function names. You will one day then have a problem, and ask franticly why your code does not work.
To compute the integral, yes, you can use a sum, which would be just rectangle rule. So clearly you would have needed to multiply by the width of the rectangle. Nor was there any need to add an abs at the end there, or even to use sum! Look at what you did:
error1=error*error';
Why did you do this, and then try to sum it up? That is a dot product. It multiplies the elements of the vector, then sums them. Had you just multiplied it by deltat, that would be the desired approximation to the integral already.
Next, learn to use MATLAB, as it is designed to be used. Instead of a loop to compute the error, just use vector operations. So one line suffices instead of the loop.
err = 1-y;
deltat = 0.1;
ise = trapz(deltat,err.^2);
Even shorter, you might have done it all in one line:
ise = trapz(0.1,(1-y).^2);
  댓글 수: 4
Sambit
Sambit 2022년 11월 24일
이동: John D'Errico 2022년 11월 24일
which function is used insted of integral squre error in simulink 2021
because it cannot run in matlab coading
John D'Errico
John D'Errico 2022년 11월 24일
편집: John D'Errico 2022년 11월 24일
Please. Do not ask questions as an answer. I've moved your question into a comment onto my answer. Anyway, your question is not even directly relevant to the one asked here by the OP, because your question is about Simulink. So really, it should be a question of its own on Answers.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by