Implicit scalar expansion doesn't work in MATLAB function block.

3 ビュー (過去 30 日間)
Kaung
Kaung 2022 年 8 月 6 日
コメント済み: Kaung 2022 年 8 月 8 日
I spent quite a lot of time trying to figure out why the same piece of function runs in MATLAB but not in a MATLAB function block called by Simulink. Then, I saw this post made two years ago about how implicit scalar expansion doesn't work for MATLAB function blocks for some reason and using bsxfun is one way to get around that. I just wanted to check if there's any update on this issue.. I'd rather not write two separate versions of the same thing if I can avoid it.
function ans = fcn()
ans = ones(4,3) .^ ones(4,1);

採用された回答

Fangjun Jiang
Fangjun Jiang 2022 年 8 月 8 日
Good news. It seems it is available in R2021b, but not in R2021a. Check
  2 件のコメント
Rik
Rik 2022 年 8 月 8 日
Although since there are no plans to remove bsxfun, you can safely write the one version with that.
And @Kaung, please don't use ans as a variable. Those code tricks you learn from Cody are terrible in every other situation.
Kaung
Kaung 2022 年 8 月 8 日
Thanks @Fangjun Jiang and @Rik for the inputs!
I just copied and pasted the code with ans :D

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSimulink Functions についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by