How to split signal in simulink?

조회 수: 13 (최근 30일)
George Francis
George Francis 2018년 3월 20일
편집: Jim Riggs 2018년 3월 21일
Hello, I have this easy model. In matlab function block I have command ulength=length(u); and it returns me 1. It should give me 30, because in red box is set time to 30. My question is if I can split somehow the signal, because I need to use in matlab function block for loop: For example:
for k=1:30
z= [-y(k-1) u(k-1)]';
end
But it shows me error: that signal 'u' and 'y' are one dimensional with one element. So is there way how to split that signal so I could work with it like in matlab workspace?
  댓글 수: 2
Birdman
Birdman 2018년 3월 20일
What are you going to do by splitting them? Explain that and maybe we'll come up with an easier way.
George Francis
George Francis 2018년 3월 20일
I have to identify data using recursive least square method which should give me 4 parameters (b0,a2,a1,a0).
b0
--------------
a2*s^2+a1*s+a0
My code which I have in matlab works fine but in simulink it doesn't work because of the loop. It won't let me access y(n-l) how it shown below because it says it's one dimensional with 1 element so dunno how to change the code that it would work in simulink.
for n=3:N
for l=1:1
V(l) = y(n-l); %output
end
for i=1:3
W(i) = u(n-i+1); %input
end
z = [V';W'];
sample_out = y(n);
C = (C - ( (C*z*z'*C)/( lamda+(z'*C*z) ) ))/lamda;
P = P + (C*z* (sample_out - (z'*P) ) );
end

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

채택된 답변

Jim Riggs
Jim Riggs 2018년 3월 20일
편집: Jim Riggs 2018년 3월 20일
I'm not sure if this is the answer to your question, but Here is how to access a signal from the previous calculation iteration, y(n-1), in Simulink:
  댓글 수: 2
George Francis
George Francis 2018년 3월 21일
Thank you for help, I actually found that I can use also unit delay block instead of memory block.
Jim Riggs
Jim Riggs 2018년 3월 21일
편집: Jim Riggs 2018년 3월 21일
Very good.
The memory block may be set to any delay you desire.
n-1, n-2, n-3, .... etc.
you specify the delay inside the block. Default is 1.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Simulink에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by