MATLAB Answers

0

How can i modify a model automatically which uses an excel file as an input when this excel file is modified (checksum is modified) ?

Asked by Lamjed ESSID on 4 Jun 2019
Latest activity Commented on by Lamjed ESSID on 4 Jun 2019
Hello everybody,
I am working on a simulink model which should be modified every time an excel file is modified. the idea is to use the getfile checksum function but i can't find a solution to make an automatic check in the model to know if the excel file is modified or not ?
Thanks in advance,

  0 Comments

Sign in to comment.

Products


Release

R2017a

1 Answer

Answer by Titus Edelhofer on 4 Jun 2019

Hi Lamjed,
does the entire Simulink model needs to be changed or only a block? If it's only a block you could mask the block and add to the mask initialization the call to update (or not).
If it is the whole model, you would need to add this to the model init function (menu File->Model Properties->Callbacks->InitFcn).
Titus

  3 Comments

Hi Titus,
Thanks for your answer, but i've tried that and it doesn't work. it works only if i run the simulation but the purpose is to make the modification automatically.
Hi Lamjed,
hmm, then I guess it will be much more involved: yes, my suggestions were aiming at modifying the model when you either do an update (Ctrl-D) or start the simulation. To happen "automatically" would require one of the two options below:
  1. Excel "tells" the Simulink model to update
  2. The Simulink model polls the state of the Excel file
Regarding 1: you might be able to use Automation Server or other techniques, but they all will require the Excel file to do some "action". I guess this is not what you want.
Regarding 2: you could start a timer in MATLAB that periodically (every ten seconds?) checks the Excel file and in case it detects changes instructs the simulink model to update
set_param(modelName, 'SimulationCommand', 'update')
Should work - but still strange. Better advice probably needs much more background information from you.
Titus
Hi Titus,
I think second idea of the timer is great, i will try it and put a response here to confirm the solution for the other users.
Thanks a lot.

Sign in to comment.