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
2012년 9월 11일
why, whithout matlab function? what do you want to do?
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
2012년 9월 12일
편집: Azzi Abdelmalek
2012년 9월 12일
at t=0; x1 and x2 are unknowns, it will not work
Azzi Abdelmalek
2012년 9월 12일
TAB, I have simulated your idea, and it did'nt work.
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
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
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
2012년 9월 12일
The question said to avoid Matlab function.
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?
Azzi Abdelmalek
2012년 9월 12일
Matlab function is supported by HDL coder. Depends on verision of matlab you are using
TAB
2012년 9월 13일
Mojtaba, If you hints us about your requirement, may be anyone can suggest a better alternative solution.
답변 (2개)
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
2012년 9월 12일
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
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)
카테고리
도움말 센터 및 File Exchange에서 Signal Generation에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!