how can I generate indices for submatrix extraction in simulink?

2 ビュー (過去 30 日間)
Simone
Simone 2014 年 3 月 8 日
回答済み: Prateekshya 2024 年 10 月 15 日
Hi,
I want to do the following function in simulink without using embedded matlab:
function index=index_gen(i1,i2)
if(i1<=i2)
index=i1:i2;
else
index=i2:i1;
end
end
is there a simulink block or is it possible to create a block which can generate a vector of indices starting from to integer values? because I need to generate dynamically a vector of indices to select a submatrix from a matrix thank you

回答 (1 件)

Prateekshya
Prateekshya 2024 年 10 月 15 日
Hello Simone,
Creating a dynamic vector of indices in Simulink without using Embedded MATLAB (now called MATLAB Function block) can be a bit challenging, as Simulink is primarily designed for signal processing and control systems rather than dynamic array operations. However, you can achieve this by using a combination of Simulink blocks and logic as follows.
  • Inputs: You need two integer inputs, i1 and i2.
  • Comparison Logic: Use a Relational Operator block to compare i1 and i2.
  • Switch Logic: Use Switch blocks to handle the logic for generating indices based on the comparison.
  • For Iterator Subsystem: Use a For Iterator Subsystem to generate the sequence of indices.
  • Output: Collect the indices into a vector.
I hope this helps!

カテゴリ

Help Center および File ExchangeSignal Attributes and Indexing についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by