Hello ,
I just started MATLAB Simule and I have a question. I have a constant value and use it in a function. I want to use function output instead of my constant value?
Someone can give me a hint?
Thank you

 채택된 답변

Jim Riggs
Jim Riggs 2018년 3월 10일
편집: Jim Riggs 2018년 3월 10일

0 개 추천

I think that the reason that no one has offered an answer to your question for the last 20 hours is, in part, because the question is unclear, but i am going to take a guess: It could be that this is what you mean:
Or maybe this:
These are reasonable guesses based on the stated desire to use "function output". However, it may be that you want to replace the constant with a calculation? (This would not be considered a "function") In that case, you can simply put the calculation in the constant block, and define any variables used in the calculation in the Matlab workspace before you run the model.
If you give more information in your question you will get better help. For example, state the actual function calculation you want to use in place of the constant, and it will be more clear.

댓글 수: 2

Metehan AYTAC
Metehan AYTAC 2018년 3월 10일
I want to use Constant value once.After that use y instead of constant. Sorry for my bad description.
Jim Riggs
Jim Riggs 2018년 3월 11일
편집: Jim Riggs 2018년 3월 11일
Here is how to do that. You use a "Switch" block to select between two signals. The first signal (on top) is the constant initial condition. The second signal (on the bottom) is the output from your function block. The middle port is the switch logic. The switch is triggered by the switch signal being compared to zero. When this middle signal is greater than zero, the top signal is selected. When the switch signal is less than or equal to zero, the botom signal is selected. Now you set up a switch signal that will be "1" for the first itteration, and "-1" for every other itteration. This is done using a constant block with "-1" value, and a memory block.
The output of the memory block is delayed by 1 iteration. Inside the memory block, set the "initial condition" to +1. This will make the output of the Memory block "1" on the first pass, and then it will pass the value of the input constant (-1) for all subsequent passes, so you have a signal series that is +1, -1, -1, -1, ...etc. This triggers the switch block to use the top signal for the first pass, and the bottom signal for all subsequent passes.
Another way to do the same thing is:
The "memory" block must have an initial condition set to +1 (actually, any positive value will do)

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Simulink에 대해 자세히 알아보기

태그

질문:

2018년 3월 10일

편집:

2018년 3월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by