simulink

Can you explain this Embedded MATLAB Function error?

余生颓废 提交于 2019-12-02 03:14:01
I'm having a problem sending a value from a GUI to an Embedded MATLAB Function (EMF) in a Simulink model. I get this value from a slider in my GUI and send it to an EMF block in my model. I can confirm that the value is being transferred correctly from my GUI to my Simulink block, since I can display the value with a display block in my model and see the value change when I change the slider position in my GUI. However I keep getting this error when I run my model: Could not determine the size of this expression. Function 'Kastl' (#18.282.283), line 14, column 1: "f" This is part of my EMF

How do I get data from a Simulink block into a MATLAB GUI?

强颜欢笑 提交于 2019-12-01 11:17:01
I have a Simulink model that uses an embedded MATLAB function for a block, and I haven't been able to figure out how to move data between the embedded MATLAB block and a GUI in real-time (i.e. while the model is running). I tried to implement a "to workspace" block in my model but I don't know how to correctly use it. Does anyone know how to move data from a Simulink block into a GUI in real-time? gnovice Non-real-time solution: If you want to set parameters in a GUI, simulate a model with those parameters, and then display the simulation output in the GUI, there is a good tutorial on

programmatically adding “matlab function” block to simuliink

北慕城南 提交于 2019-12-01 10:00:30
问题 can anyone tell me how to add the "MATLAB Function" block to a simulink model which I am constructing programmatically? Once I add it, I will also need to know how to modify the code, which doesn't seem to be hiding inside any of the parameters I get from get_param(my_fcn_block,'ObjectParameters') . As a workaround I'm currently saving a customised block to my library and inserting this with add_block('my_lib/my_fcn_block','my_fcn_block') 来源: https://stackoverflow.com/questions/19494423

Load code for a MATLAB function block at Simulink runtime

你离开我真会死。 提交于 2019-12-01 08:32:13
I would like to have some file, myfunc.m , in my MATLAB path and somehow load its contents into a MATLAB function block automatically just before the simulation starts. This way, I can use an external editor to write these embedded function, version control them separately as independent files, etc. Is there a way to achieve this programmatically? My initial attempt was to try and access the contents of the function block using something like get_param , but I can't seem to gain read/write access to the code itself. Florian Brucker If the target MATLAB Function block doesn't already exist then

How do I get data from a Simulink block into a MATLAB GUI?

僤鯓⒐⒋嵵緔 提交于 2019-12-01 08:07:38
问题 I have a Simulink model that uses an embedded MATLAB function for a block, and I haven't been able to figure out how to move data between the embedded MATLAB block and a GUI in real-time (i.e. while the model is running). I tried to implement a "to workspace" block in my model but I don't know how to correctly use it. Does anyone know how to move data from a Simulink block into a GUI in real-time? 回答1: Non-real-time solution: If you want to set parameters in a GUI, simulate a model with those

Load code for a MATLAB function block at Simulink runtime

北慕城南 提交于 2019-12-01 07:48:57
问题 I would like to have some file, myfunc.m , in my MATLAB path and somehow load its contents into a MATLAB function block automatically just before the simulation starts. This way, I can use an external editor to write these embedded function, version control them separately as independent files, etc. Is there a way to achieve this programmatically? My initial attempt was to try and access the contents of the function block using something like get_param , but I can't seem to gain read/write

Circular Buffer in Simulink

99封情书 提交于 2019-12-01 01:03:13
I would like to implement a very huge (10^6 Elements - fixed size) circular buffer in pure Simulink model (no further toolboxes, no S-Function ). At some points I need to read some elements (anywhere, not just begin or end). The following solutions I can not use: "Queue Block" or "Buffer Block" (I have no Signal Processing Toolbox available) "Discrete Delay" ( I need a hugh buffer and will not place 10^6 delays into the model) "Sim Events" (I need to generate code from this model) The "S-Function" I tried not yet, and I am looking for an alternative solution. What further approach do you know?

Obtaining the model topology from a Simulink model

半腔热情 提交于 2019-11-30 22:19:47
I would like to create a structure in Python which represents a Simulink model. I am aware of at least two ways of doing this - by parsing an ".mdl" file, or by using Matlab's api for communicating with the model. Can you recommend good libraries or APIs for doing this? In particular, I need to perform some processing on a Simulink model and I would like to do it in Python. Also I don't want to be constantly communicating with Matlab for doing this (so that I can release the floating license). I have seen some parsers online, but they seem to be a little limited, usually not supporting

control simulink from M-file

馋奶兔 提交于 2019-11-30 20:37:58
问题 I am trying to control a simulink from a M-file. What I want to do in the M-file is give the simulink model some input, run the simulink model, change one input value at 0.6 seconds, continue running the simulink model with the new input. I already know that by using set_param, I can start, pause and continue the simulink, but the problem is I don't know how to pause the simulink model at a certain time(0.6s), is it possible to get the current time from simulink model and read it in the M

How to save scope to an image file without using plot?

无人久伴 提交于 2019-11-30 17:48:48
问题 This condition is very important, because plot stretches my graph in an unacceptable manner. 回答1: If the comment by MikeT is correct, and you are trying to save the image shown in a Scope block, there are a couple of ways you could do this: Print the contents of the scope window by clicking the Print icon, the leftmost icon on the Scope toolbar. Then choose to print to a file instead of to a printer. Create an editable figure from a scope block using the SIMPLOT function. This will create a