MATLAB Answers

subsref works as not expected

1 ビュー (過去 30 日間)
Sergey Kasyanov
Sergey Kasyanov 2021 年 1 月 12 日
コメント済み: Sergey Kasyanov 2021 年 1 月 12 日
Hello!
Let's create random cell array.
test = {1,2,3,4};
And try to evaluate simple code
res_1 = ones(subsref(test, substruct('{}', {':',':'})));
res_2 = ones(test{:, :});
Results unmatch but it should to match according with subsref help. Why?
Is there any way to unpack cell array without direct access through {:}?

採用された回答

Bruno Luong
Bruno Luong 2021 年 1 月 12 日
編集済み: Bruno Luong 2021 年 1 月 12 日
I knew it for sometime: subsref never work to emulate comma list (not sure if it's documented), because a non trivial comma list (with length > 1) can never be considered as function output .
This limitation surely deserves to be in "what frustrates you ..." thread.
  3 件のコメント
Sergey Kasyanov
Sergey Kasyanov 2021 年 1 月 12 日
Thanks!

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by