Make simulink custom task run sequentially

2 visualizzazioni (ultimi 30 giorni)
Reuben Symons
Reuben Symons il 28 Giu 2022
Risposto: Karan Singh il 29 Set 2023
I have a custom task function that runs fin on a single model but when I run it with Custom Task on all the models in my project I get a problem where for models which are made up of other models the function won't run because the sub models are already opened by the master model.
I could filter the models before running to not select any sub models but as I am not going to be the only person running this script would rather not do this.
Is there a way to force the custom task to run on each of the models sequentially instead of trying to open them in parrallel.

Risposte (1)

Karan Singh
Karan Singh il 29 Set 2023
Hi Reuben,
From what I understand, issue you are facing is related to running a custom task function on multiple models within your project. You are seeking a solution that allows the custom task to run on each model sequentially, rather than trying to open them in parallel.
This can be achieved by using a loop to iterate over the models and calling your custom task function for each model individually. Here's an example of how you can modify your custom task function to run sequentially on each model:
function runCustomTaskOnModels()
% Load the project containing the models
project = loadProject('path/to/your/project.prj');
% Get a list of all the models in the project
models = project.Models;
% Iterate over each model and run the custom task function
for i = 1:numel(models)
model = models(i);
% Call your custom task function for the current model
customTaskFunction(model);
end
end
function customTaskFunction(model)
% Your custom task function implementation
% Perform the necessary operations on the model
% Example: Display the model name
disp(model.ModelName);
% Example: Run finite element analysis on the model
results = solvepde(model);
% Example: Save the results to a file
saveResultsToFile(results);
end
In this example, the runCustomTaskOnModels function loads the project and retrieves a list of all the models. It then iterates over each model using a loop and calls the customTaskFunction for each model. Inside the customTaskFunction, you can perform the necessary operations specific to your task.
Hope this helps!
Karan Singh Khati

Prodotti


Release

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by