How to do array operation With simulink blocks ?

조회 수: 2 (최근 30일)
Sasidhar Duggireddy
Sasidhar Duggireddy 2019년 5월 28일
답변: Sasidhar Duggireddy 2019년 6월 12일
I was designed below code with State flow. But I unable to do with the Simulink blocks.
please let me know, how to with the Simulink.
uint8 sampleFunction(uint8 *A, uint8 *B)
{
for(i=0;i<n;i++)
{
Temp = 0;
if(A[i] == B[i])
{
Temp = A[i] + B[i];
}
}
return Temp;
}
  • > How we can take dynamic array ?

채택된 답변

Sasidhar Duggireddy
Sasidhar Duggireddy 2019년 6월 12일
Please find the below example for more idea about for loop.
I hope this example can help
Capture.JPG

추가 답변 (1개)

Nick Sarnie
Nick Sarnie 2019년 6월 5일
편집: Nick Sarnie 2019년 6월 5일
Hi Sasidhar,
It looks like that loop is adding two matricies. The "Add" or "Sum" block can do this:
If the matrix size is constant once the simulation has started, you can simply set the dimensions in the block parameters. To make it easier, consider using Simulink.Parameters for the dimensions instead.
If the matrix size will change between simulation steps, you can use variable size signals.
Thanks,
Nick
  댓글 수: 2
Sasidhar Duggireddy
Sasidhar Duggireddy 2019년 6월 6일
Hello Nick
I know how do addition of two scalars(numbers) with add operator. I want know how to add the array elements with one constant or array of elements.
Thanks for your reply.
Nick Sarnie
Nick Sarnie 2019년 6월 6일
Hi Sasidhar,
Can you provide an example of this operation?
Thanks,
Nick

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by