Illegal use of 'end' in Simulink Coder when copying code from MATLAB to simulink function block
3 ビュー (過去 30 日間)
古いコメントを表示
I have attached a picture to what I mean by this error. Any help would be appreciated on how I could overcome this error. This is usually how i code using the matlab coder but i think the matlab function in simulink doesn't accept a lot of syntax.
Thanks!
0 件のコメント
回答 (2 件)
VBBV
2022 年 2 月 1 日
Remove the word end from brackets
3 件のコメント
VBBV
2022 年 2 月 1 日
SampleTemperatureHeating(length(SampleTemperatureHeating))
When you use length(yourarray) it gives largest value of array dimension. This means maximum number of elements in array. If you use in parenthesis () matlab will return the last value in that array. But this is usually not recommended as when your code gets larger, it becomes difficult to debug at later stage. That's why assign it to variable and call that variable inside the array.
K = length(SampleTemperatureHeating)
SampleTemperatureHeating(K)
Les Beckham
2022 年 2 月 1 日
It looks to me like the problem in that screenshot is a typo: "Heaating" vs. "Heating" in the variable name which you are trying to index with (end).
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!