Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

How to use for loop in m-function in SIMULINK for Online tuning?

조회 수: 2 (최근 30일)
Nitesh
Nitesh 2015년 8월 13일
마감: MATLAB Answer Bot 2021년 8월 20일
Using m-function for online ILC iteration update (P-type Law), how can compute, store and update for the next cycle?
Note-Both equation are similar.
I am using ICL P-type update law (any above eq) where im calling a m-function which will take parameters into the .m file (function ILC) directly and feed it out into the PID controller. I am to iterate the whole CL system for at least 20 trials using the equation where
uk(t)/xdi'(t) is the input for the plant from the whole controller
ek(t)/ei(t+1) is the error
sum is stored in uk+1(t)/xd(i+1)(t)
L/Lambda= learning gain which can be constant of 0.04.
my codes in the ILC m-function are as follow:
function uk1 = ILC(uk,ek)
%#codegen
uk1=0
L=0.04
uk1=uk+L*ek;
uk1=uk
end
using the above codes, it works ok but i cannot confirm if the iteration is happening or no because no value is stored as array. OR do i need a for loop to iterate ILC?
function uk1 = ILC(uk,ek)
%#codegen
t=20
uk1=0
L=0.04
for n=1:1:t
uk1(n)=uk(n)+L*ek(n);
uk1=uk(n)
end
If i do the for loop,error of 'Attempted to access element 2. The valid range is 1-1.' ERROR yields. Please can you help me with the function codes also.
How should i implement the iteration, with or without the for loop?

답변 (0개)

이 질문은 마감되었습니다.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by