I am getting an error for the below eqn . I wrote coding in matlab function (user defined function in simulink),so please help with this.I have also attached my simulink model.

function y = fcn(h,u)
A = [0 1;-1 1];
B = [0;1];
N = 300;
y = zeros(1,500);
t = 0:25
for i = 1:N
y = (h/N)*exp(i*A*(h/N)).*B*u(t-(i*(h/N)));

댓글 수: 1

@Chiliveri Vinod: please show us the complete error message. This means all of the red text.

답변 (1개)

madhan ravi
madhan ravi 2018년 11월 3일
편집: madhan ravi 2018년 11월 3일
function y = fcn(h,u)
A = [0 1;-1 1];
B = [0;1];
N = 300;
y = zeros(1,500);
t = 0:25
for i = 1:N
y(i)= (h/N)*exp(i*A*(h/N)).*B*u(t-(i*(h/N)));
end
y
end

댓글 수: 4

You left two ends at the end missing
@Madhan: the code overwrites y in every single run of the Loop.
thank u for the answer but i want the output as (2,1) dimension ,it is getting as (1,500)

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

태그

질문:

2018년 11월 3일

마감:

2021년 8월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by