Workspace in Matlab shows value not formula

2 visualizaciones (últimos 30 días)
Stefan Kumpe
Stefan Kumpe el 3 de Mayo de 2021
Comentada: Stefan Kumpe el 5 de Mayo de 2021
Hello to all friendly people in this forum,
i must be missing something.
When i create a variable in Simulink, it is shown in the Workspace of MatLab.
But instead of the formula, i can only see and edit a decimal number.
Many Thanks.
  2 comentarios
Walter Roberson
Walter Roberson el 3 de Mayo de 2021
How are you creating the value in Simulink?
Tom Fischer
Tom Fischer el 4 de Mayo de 2021
Editada: Tom Fischer el 4 de Mayo de 2021
Either i create it by clicking on the three dots of any block like Constant or Step --> create Variable --> entering a value
or i create it directly in the MatLab Workspace
Here is shown the first step - when i enter something like "m_dot_in*p*r*d" for the value of m_dot_out,
i can only see and copy the value of the equation.
What i want is to edit the formula, not the value.

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 4 de Mayo de 2021
Editada: Walter Roberson el 4 de Mayo de 2021
When you do the Create of the variable, give it a nominal value such as 1. Then find the variable in the model "External Data" section of the model explorer, and left click on it. Then right click and select "Convert to parameter object". The far right of the explorer will change to show a Simulink.Parameter configuration. Go over to the Value section (near the top), and type in an = followed by the formula you want, such as
=m_dot_in*p*r*d
The equals-sign is important -- though if you forget it then the interface will give you a warning.
If you look in the Base Workspace, you will now see that m_dot_out has a value similar to
m_dot_out =
Parameter with properties:
Value: slexpr("m_dot_in*p*r*d")
CoderInfo: [1×1 Simulink.CoderInfo]
Description: ''
DataType: 'auto'
Min: []
Max: []
Unit: ''
Complexity: 'auto'
Dimensions: -1

Más respuestas (1)

Stefan Kumpe
Stefan Kumpe el 5 de Mayo de 2021
Hi Walter,
Thank your very much for your quick answer.
This is a pretty unhandy approach, but it works!
I get a warning as you can see in the picture.
Do you have any ideas how i can solve them?
Many Thanks!
  2 comentarios
Walter Roberson
Walter Roberson el 5 de Mayo de 2021
Code generation, especially for fixed point or HDL, typically tries to remove division, as division is one of the more expensive operations. If you can define "days_per_filling" as the reciprocol of n_fillings_per_day then you can convert to multiplication.
Stefan Kumpe
Stefan Kumpe el 5 de Mayo de 2021
Ok, thank you very much.

Iniciar sesión para comentar.

Categorías

Más información sobre Interactive Model Editing en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by