How to delete an element from a Simulink.S​imulationD​ata.Datase​t

7 ビュー (過去 30 日間)
Camille Yver
Camille Yver 2021 年 11 月 15 日
コメント済み: Camille Yver 2021 年 11 月 19 日
Hello,
I am using Simulink.SimulationData.Dataset to feed a signal builder. I have a script that analyse differerences between inputs of my model and datasets stored in .mat in order to have the same amount and same names between model and scenarios defined in thoses .mat.
If I add a new input in my model, it is easy to add an element in my dataset
diff = setdiff(modelInputNames,inputNames); % modelInputNames is the input list in model, inputNames is the input list in .mat
if ~isempty(diff)
for j = 1 : length (diff)
zeroInput = timeseries(0,ds{1}.Time); %Creating an Input with zeros, to be modified with signal builder UI
ds = ds.addElement(zeroInput,char(diff(j)));
end
end
But if I supress an input in the model, I can't find a way to delete an Element in 'ds'.
diff = setdiff(inputNames,modelInputNames); % modelInputNames is the input list in model, inputNames is the input list in .mat
if ~isempty(diff)
for j = 1 : length (diff)
%Something to delete the element diff(j) in ds
end
end
Sorry if the question is trivial, but I just can't find the right way !
Thank you

採用された回答

Salman Ahmed
Salman Ahmed 2021 年 11 月 19 日
Hi Camille,
You could use removeElement to delete an element. To remove the jth element from your Simulink.SimulationData.Dataset, use the command below :
ds = ds.removeElement(j);
  1 件のコメント
Camille Yver
Camille Yver 2021 年 11 月 19 日
Thank you ! I must have missed this in the documentation.

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by