The result of a loop statement is different from iterating over a function in model predictive control.
    조회 수: 3 (최근 30일)
  
       이전 댓글 표시
    

This is my fuction code. The first time I ran the function with r1 and r2 equal to 1, y1 was 0 and y2 was 1.06. The next time I ran the function (with y1 equal to 0 and y2 equal to 1.06), y1 was 0. 0012 and y2 was 1.0557.
 However, when I iterate using for, the first case is the same, but the second iteration (when i=2) gives me y(1) of 0.6943 and y(2) of 1.0396. Why is this difference?
 please help me.
댓글 수: 0
답변 (1개)
  Song-Hyun Ji
    
 2023년 7월 19일
        Would you elaborate what is your code inside of "for loop"? In the captured image's code, I cannot see the index "i" is using inside for loop like the following mpcmove function example.
t = 0:ts:40;
N = length(t);
y = zeros(N,1); 
u = zeros(N,1); 
for i = 1:N
    y(i) = 0.25*xc.Plant;
    u(i) = mpcmove(mpcobj,xc,y(i),r);
end
댓글 수: 0
참고 항목
카테고리
				Help Center 및 File Exchange에서 Waveform Generation에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

