MATLAB Answers

Is there a way to get the Simulink real-time parameter set (rtp) from a rapid accelerator build without rebuilding it?

14 ビュー (過去 30 日間)
Robert
Robert 2017 年 8 月 23 日
コメント済み: Lee 2017 年 10 月 30 日
I am building and using a rapid accelerator target for myModel using
rtp = Simulink.BlockDiagram.buildRapidAcceleratorTarget(myModel);
newRtp = Simulink.BlockDiagram.modifyTunableParameters(rtp, 'myParam', myValue);
sim(myModel, 'SimulationMode', 'rapid', ...
'RapidAcceleratorUpToDateCheck', 'off', ...
'RapidAcceleratorParameterSets', new_rtp);
If I don't have an rtp object (but I know my model hasn't changed and I want to run in rapid mode without re-building the model) can I get rtp from the model somehow (without re-building)?
Something like:
Simulink.BlockDiagram.buildRapidAcceleratorTarget(myModel); % oops, should have captured the output
rtp = Simulink.BlockDiagram.getExistingRapidAcceleratorTarget(myModel); % does something like this exist?

  0 件のコメント

サインインしてコメントする。

回答 (1 件)

Nirja Mehta
Nirja Mehta 2017 年 8 月 30 日
You can check the checksum of your model and get rtp only if checksums are different.
% To compile the model before calling Simulink.BlockDiagram.getChecksum
myModel([],[],[],'compile')
[cs1,csdet1]=Simulink.BlockDiagram.getChecksum(myModel);
% Get rtp for first time
rtp = Simulink.BlockDiagram.buildRapidAcceleratorTarget(myModel);
[cs2,csdet2]=Simulink.BlockDiagram.getChecksum(myModel);
if (cs1 ~= cs2)
% This means your model changed, time to update rtp
rtp = Simulink.BlockDiagram.buildRapidAcceleratorTarget(myModel);
end
% Your code now
newRtp = Simulink.BlockDiagram.modifyTunableParameters(rtp, 'myParam', myValue);
sim(myModel, 'SimulationMode', 'rapid', ...
'RapidAcceleratorUpToDateCheck', 'off', ...
'RapidAcceleratorParameterSets', new_rtp);
Hope this helps.

  3 件のコメント

Lee
Lee 2017 年 10 月 30 日
This is a great question, and I have run into the same issue. However, this response does not answer the OP request... He specifically notes that he wants to get the rtp object WITHOUT rebuilding, and your code suggestion first builds the model. I too am having to perform this build everytime i run my code, so it would be nice to do the following 2 things: 1. run a check as to whether the model has changed since it was last built. 2. if answer to 1 is no, get the rtp object without building.
In many situations, this would save the time spent building. The only workaround I can think of is saving the checksum to a file next to the model whenever it's built. Then the next time i run the code, it loads this file to compare it to current checksum like you have in this suggestion. But I still need to get rtp structure somehow...
Robert
Robert 2017 年 10 月 30 日
Thanks, Lee, for helping to clarify my question. You are exactly right. I am looking for something along the lines of ` 'RapidAcceleratorUpToDateCheck', 'off' but for Simulink.BlockDiagram.buildRapidAcceleratorTarget. This would allow me to run the rapid accelerator target using sim and modifying the parameter in rtp without rebuilding the model.
The simplest solution is to save rtp to a *.mat file whenever I create it in case I want to load it back in to be used in a simulation later. But it seems to me that there should be a better way.
Lee
Lee 2017 年 10 月 30 日
Does saving and reloading the rtp object even work? I've had strange behaviors when reloading saved objects in the past so hadn't even tried it yet... In theory this is a solution, but i agree, no where near as elegant as your proposed function call. Mathworks?

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by