Azzera filtri
Azzera filtri

How can i search for a specific Constant Value?

13 visualizzazioni (ultimi 30 giorni)
Durgesh
Durgesh il 16 Nov 2012
How can i search for, or list, only the constant values (their path, or a list with a link) in the model which has some specific constant value. Eg. i have a simulink model and i would like to search for constants which has a value of 8. It would be so grateful to me if someone could help me.

Risposte (1)

C.J. Harris
C.J. Harris il 16 Nov 2012
Modificato: C.J. Harris il 16 Nov 2012
This will search through your Simulink model for any constant containing the value of '8'. However, when you retrieve the 'Value' field of the Constant it is stored as a string, so it will only find constant that have the value of 8, not constant blocks that reference a variable holding the numeric value of 8.
nModelName = 'YourModel';
load_system(nModelName)
sys = get_param(nModelName, 'Handle');
gb = find_system(sys, 'BlockType', 'Constant');
h = find_system(gb,'Value','8');
if ~isempty(h)
for a = 1:length(h)
disp([get_param(h(a), 'Parent'), '/', get_param(h(a), 'Name')])
end
end

Categorie

Scopri di più su Programmatic Model Editing in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by