multi level indexing acess
1 回表示 (過去 30 日間)
古いコメントを表示
I want to get output from below code but Matlab thrown Error:
[1 2 3 4](2)
My desired output is 2.
Note: I need one line answer without using any function.
Thanks
0 件のコメント
回答 (2 件)
Walter Roberson
2015 年 6 月 14 日
編集済み: Walter Roberson
2015 年 6 月 14 日
I would probably use something like:
Index = @(V,K) V(K);
and then Index([1 2 3 4],2)
If I felt especially obscure there would always be
subsref([1 2 3 4], struct('type','()','subs', {[2]})
which is what will happen internally
0 件のコメント
Azzi Abdelmalek
2015 年 6 月 14 日
編集済み: Azzi Abdelmalek
2015 年 6 月 14 日
v=[1 2 3 4]
v(2)
If you want one line, then just write
v=2
参考
カテゴリ
Help Center および File Exchange で Get Started with MATLAB についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!