How can I add a constant to a variable during a simulation in Simulink?

조회 수: 9 (최근 30일)
Marta Costa de Aguirre
Marta Costa de Aguirre 2022년 3월 22일
댓글: Mathieu NOE 2022년 4월 8일
I want to make the percentage of one variable. The operation is (initial value - final value)/ initial value. The initial value is a constant (2.646) and the final value is changing over time. I have performed the calculation with blocks shown below, but it cannot be solved because initial value is a constannt and final value changes over time.
So my question is, how can I make this operation in Simulink?
Thanks

답변 (1개)

Mathieu NOE
Mathieu NOE 2022년 3월 23일
hello
I had no particular problem doing the same simulink model and running it . what is your issue ??
NB : you post that the initial value is a constant (2.646) and in your simulink model is 0.2646.
attached my model fyi
the variable (final) value is a sinus of amplitude 1
the plot shows that this generates a variation of +/- 40 % around 100%
  댓글 수: 2
Marta Costa de Aguirre
Marta Costa de Aguirre 2022년 4월 6일
Hello,
Yes, there was a mistake in my typing. The constant value is 0.2646.
Thanks for your answer but I still cannot run it. It gives me this error: Invalid matrix variable specified as workspace input in 'DosageAllCodesnewklak6k8/[Ci]0 Initial concentration of component i inside the reactor, mmol//L/From Workspace3'. The matrix data must be a real, double, have two dimensions, and at least two columns. The first column must contain time values and the remaining columns the data values. Matrix values cannot be Inf or NaN.
I think my problem is with out.TOCb. It is a vector 189x1 and Simulink wants it with the time, so its dimension should be 189x2. So, how can I get out.TOCb as 189x2?
Should I change something in 'To Workpace'?
Mathieu NOE
Mathieu NOE 2022년 4월 8일
hello
I don't think we have a problem with out.TOCb because this is a "To Worspace" block
your error message deals with a "From Worspace" block.
'DosageAllCodesnewklak6k8/[Ci]0 Initial concentration of component i inside the reactor, mmol//L/From Workspace3'.
This block needs to be initialized with a 2 column array (time and data)
The faulty block should be highlighted in yellow in you simulink file

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

카테고리

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