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

조회 수: 18 (최근 30일)
Peman
Peman 2025년 12월 16일 18:14
댓글: Fangjun Jiang 2025년 12월 17일 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

채택된 답변

Fangjun Jiang
Fangjun Jiang 2025년 12월 16일 18:35
편집: Fangjun Jiang 2025년 12월 16일 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
Peman
Peman 2025년 12월 16일 20:01
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 2025년 12월 17일 14:38
Yes. Now it definitely reminds me that matching case was not required before.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Composite Interfaces에 대해 자세히 알아보기

제품


릴리스

R2025b

Community Treasure Hunt

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

Start Hunting!

Translated by