Unrecognized method, property, or field 'elements' for class 'Simulink.Bus'.

16 visualizaciones (últimos 30 días)
Peman
Peman el 16 de Dic. de 2025 a las 18:14
Comentada: Fangjun Jiang el 17 de Dic. de 2025 a las 14:38
Hello,
I have a project initially designed in MATLAB R2011b and opened it in MATLAB R2025b and got the following error. Any idea how to fix this issue? It seems like the 'elements' method no longer exists (deprecation) on the 'Bus' object. Below is also the piece of code that is causing this issue.
Error: Unrecognized method, property, or field 'elements' for class 'Simulink.Bus'.
Code causing error above:
function busOut = funSetSamplingtimeBus(bus, samplingtime)
for index = 1:length(bus.elements),
bus.Elements(index).Sampletime = samplingtime;
end
busOut = bus;
end
Thanks,
PM

Respuesta aceptada

Fangjun Jiang
Fangjun Jiang el 16 de Dic. de 2025 a las 18:35
Editada: Fangjun Jiang el 16 de Dic. de 2025 a las 18:47
It should be .Elements with the capital "E". It might be that in the older version, it was not enforced to match the case between MyBus.elements and MyBus.Elements.
  2 comentarios
Peman
Peman hace 10 minutos
That fixed the issue. Thanks a lot!
Note: .Sampletime had also be changed to .SampleTime for this piece of code to work.
Fangjun Jiang
Fangjun Jiang hace alrededor de 6 horas
Yes. Now it definitely reminds me that matching case was not required before.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Composite Interfaces en Help Center y File Exchange.

Productos


Versión

R2025b

Community Treasure Hunt

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

Start Hunting!

Translated by