Rapid Accelerator Simulation
21 ビュー (過去 30 日間)
古いコメントを表示
I am running a simulation on bunch of differnt matfiles. My model can indvidually run in Rapid Accelerator mode but I can not figure out a way to run the whole sim in a for loop simulating each matfile....WITHOUT BUILDING RAPID ACCELETOR EACH TIME.
Here is how my code looks like
for i=1:100
filename = filelist(i)
load(filename) %This one loads, 11 (say V1 to V11) variables from the file into Matlab workspace
Process data, create time vector and initialize simulink variable
mdl = 'Mymodel.mdl'
sim(mdl,'SimulationMode', 'rapid')
end
so in this example, my code will build rapid accelerator target every single time for each loaded file (100 times). Which consumes lots of time.
I tried using,
if (i == 1)
load_system(mdl);
rtp = Simulink.BlockDiagram.buildRapidAcceleratorTarget(mdl);
sim(mdl,'SimulationMode', 'rapid');
else
sim(mdl,'SimulationMode', 'rapid','RapidAcceleratorUpToDateCheck','off');
end
Here it builds rapid accelerator target only for the first time, but for all subsequent runs, it uses the exact model that it built from (first loaded model + workspace) and my workspace variables dont get assigned to model every time Basically all my 100 runs produce same results.
My question is.... Is there any way to assign new variables from workspace to already built simulation target model and run the sim in for loop?
paramName = {'V1', 'V2', 'V3',...'V11'}
paramValue = {Cspeed, CTemp, Cflow,...,Cvar };
sim(mdl, paramName, paramValue,'SimulationMode', 'rapid','RapidAcceleratorUpToDateCheck','off')
(In my sim model, there is one input block where I assign all the 11 loaded workspace variable to 11 simulink blocks)
0 件のコメント
採用された回答
Kaustubha Govind
2012 年 4 月 9 日
You can only change tunable parameters after the rapid accelerator target has been built. You can figure out if a parameter is tunable or non-tunable by looking at the parameter attributes list that can be obtained using get_param(gcb, 'DialogParameters'). This command returns a structure with the block parameter names as fields. Each field further is a structure that has an "Attributes" field. The list of attributes will contain 'read-only-if-compiled' for non-tunable parameters.
0 件のコメント
その他の回答 (2 件)
Jayesh Kavathe
2012 年 4 月 9 日
2 件のコメント
Kaustubha Govind
2012 年 4 月 10 日
Is your "Input" block a subsystem containing "From Workspace" blocks? You'll need to run the get_param command I suggested on the From Workspace blocks. In any case, I ran that command on the block, and the "VariableName" parameter is non-tunable, so you cannot modify them without rebuilding your rapid accelerator target. The reason that this parameter is non-tunable is because the type/size of this parameter value determines the output signal type/size, which will affect the types/sizes propagated throughout the model. I think the better approach for your case might be to replace the From Workspace blocks with Inport blocks, and use the model Data Import/Export pane to import the data from workspace. You will need to ensure that the type/size of the data does not change between simulations.
Jayesh Kavathe
2012 年 4 月 16 日
2 件のコメント
K E
2012 年 4 月 16 日
You might want to ask this as a separate question since it is separate from your original question.
Kaustubha Govind
2012 年 4 月 16 日
I agree with KE. Also, I think just assigning Exhaust_Flow.Value to a different value before each simulation should work. When you create a new question please specify why that doesn't work.
参考
カテゴリ
Help Center および File Exchange で Acceleration についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!