variable discrete vector generation in Simulink

I need to make sequence (1D vector) from 2 constants in Simulink.
e.g.: x1=1 and x2=10 as input constant
Desired vector: X=[1 2 3 4 5 6 7 8 9 10]
I know It is very easy to generate such vector in matlab, but I really want to do it in terms of blocks and not even Embedded Matlab Function Block.
Thanks in Advance

14 件のコメント

Azzi Abdelmalek
Azzi Abdelmalek 2012 年 9 月 11 日
why, whithout matlab function? what do you want to do?
TAB
TAB 2012 年 9 月 12 日
Save x1=1 & x2=10 in base workspace. Take a constant block in simulink & put the value as [x1:x2]
Azzi Abdelmalek
Azzi Abdelmalek 2012 年 9 月 12 日
編集済み: Azzi Abdelmalek 2012 年 9 月 12 日
at t=0; x1 and x2 are unknowns, it will not work
TAB
TAB 2012 年 9 月 12 日
編集済み: TAB 2012 年 9 月 12 日
@Azzi Abdelmalek: x1 and x2 are in base workspace, so they will be evaluated during model update. So at t=0, values will be available in constant block.
Can you let me know how you have tried this ?
Azzi Abdelmalek
Azzi Abdelmalek 2012 年 9 月 12 日
TAB, I have simulated your idea, and it did'nt work.
TAB
TAB 2012 年 9 月 12 日
Ok, from "Save x1=1 & x2=10 in base workspace", I mean save these variables manually from command window before simulation.
Azzi Abdelmalek
Azzi Abdelmalek 2012 年 9 月 12 日
編集済み: Azzi Abdelmalek 2012 年 9 月 12 日
But during simulation, they can't be updated,I guess x1 and x2 are outputs of other blocks
Kaustubha Govind
Kaustubha Govind 2012 年 9 月 12 日
Azzi: I think TAB is saying that x1 and x2 should be parameters to the MATLAB Function block, not inputs.
Azzi Abdelmalek
Azzi Abdelmalek 2012 年 9 月 12 日
The question said to avoid Matlab function.
Mojtaba
Mojtaba 2012 年 9 月 12 日
編集済み: Mojtaba 2012 年 9 月 12 日
Making x1 and x2 as variable and the using a constant block [x1:x2]works but the problem is that x1 and x2 change during the simulation.
Azzi Abdelmalek
Azzi Abdelmalek 2012 年 9 月 12 日
編集済み: Azzi Abdelmalek 2012 年 9 月 12 日
Mojtaba, just one question: matlab functions make our life much easier, why want you avoid them?
Mojtaba
Mojtaba 2012 年 9 月 12 日
編集済み: Mojtaba 2012 年 9 月 12 日
my advisor told me that do not use them because after completing the simulation model we are going to make the code out of it(maybe HDL/PLC code) that if we use embedded matlab block it is not possible to do it. Have you ever heard of it?
Azzi Abdelmalek
Azzi Abdelmalek 2012 年 9 月 12 日
Matlab function is supported by HDL coder. Depends on verision of matlab you are using
TAB
TAB 2012 年 9 月 13 日
Mojtaba, If you hints us about your requirement, may be anyone can suggest a better alternative solution.

サインインしてコメントする。

回答 (2 件)

Kaustubha Govind
Kaustubha Govind 2012 年 9 月 12 日
編集済み: Kaustubha Govind 2012 年 9 月 12 日

0 投票

Mojtaba: Do x1 and x2 change during simulation? If not, try defining them as workspace variables.
  • Constant block: Enter [x1:x2] as Value.
  • MATLAB Function block: Make them non-tunable parameters on the block's Ports and Data Manager and compute output using [x1:x2].

2 件のコメント

Mojtaba
Mojtaba 2012 年 9 月 12 日
yes they change during simulation.
Kaustubha Govind
Kaustubha Govind 2012 年 9 月 13 日
I think this is a lot harder to do. You will need to understand Variable-Size Signals because if x1 and x2 change during simulation, the size of the signal also changes. I don't see any easy way to do this without the MATLAB Function block, but even with that block, I think this will be tricky.

サインインしてコメントする。

Azzi Abdelmalek
Azzi Abdelmalek 2012 年 9 月 12 日
編集済み: Azzi Abdelmalek 2012 年 9 月 12 日

0 投票

check the blocks supported by HDL coder at http://www.mathworks.com/help/hdlcoder/ug/summary-of-block-implementations.html at the end of the page(simulink/User-Defined Functions/MATLAB Function)
MATLAB Function (was Embedded function for previous versions)

製品

タグ

質問済み:

2012 年 9 月 11 日

Community Treasure Hunt

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

Start Hunting!

Translated by