function函数​中元胞数组cell的​索引问题?

56 Ansichten (letzte 30 Tage)
新百胜娱乐公司l7787482287
定义了一个function函数后,我发现想在function函数中对函数外的cell函数进行索引出现了问题,正常的索引是用{},但是我用{}进行cell索引的话Matlab显示此类型的变量不支持使用花括号进行索引,不是我的cell有问题,在function外面我进行了索引是正常的,程序很复杂,这里我举一个简单的例子:
  1. clear
  2. ist_tab = {[1,2,3],[4,5,6]};
  3. ist_tab{1}
  4. ist_tab{2}
  5. abc(1)
  6. function ab = abc(z)
  7. global ist_tab
  8. ab = ist_tab{z};
  9. end
matlab会提示“此类型的变量不支持使用花括号进行索引”
这个程序中在function外面ist_tab这个cell是可以用{}索引的,但是放到function里面就不行了,有大佬晓得怎么在function里索引元胞数组么?

Akzeptierte Antwort

腾龙娱乐开户l7787482287
  1. clear
  2. global ist_tab
  3. ist_tab = {[1,2,3],[4,5,6]};
  4. ist_tab{1}
  5. ist_tab{2}
  6. abc(1)
  7. function ab = abc(z)
  8. global ist_tab
  9. ab = ist_tab{z};
  10. end

Weitere Antworten (0)

Kategorien

Mehr zu 输入命令 finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!