Definition of Integral Square Error via matlab (ISE)

143 visualizzazioni (ultimi 30 giorni)
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))

Risposta accettata

John D'Errico
John D'Errico il 28 Ago 2017
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 Commenti
Sambit
Sambit il 24 Nov 2022
Spostato: John D'Errico il 24 Nov 2022
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 il 24 Nov 2022
Modificato: John D'Errico il 24 Nov 2022
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.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Startup and Shutdown in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by