function函数中元胞数组cell的索引问题。
조회 수: 23 (최근 30일)
이전 댓글 표시
定义了一个function函数后,我发现想在function函数中对函数外的cell函数进行索引出现了问题,正常的索引是用{},但是我用{}进行cell索引的话Matlab显示此类型的变量不支持使用花括号进行索引,不是我的cell有问题,在function外面我进行了索引是正常的,程序很复杂,这里我举一个简单的例子:
clear
ist_tab = {[1,2,3],[4,5,6]};
ist_tab{1}
ist_tab{2}
abc(1)
function ab = abc(z)
global ist_tab
ab = ist_tab{z};
end
matlab会提示“此类型的变量不支持使用花括号进行索引”。
这个程序中在function外面ist_tab这个cell是可以用{}索引的,但是放到function里面就不行了,有大佬晓得怎么在function里索引元胞数组么?
댓글 수: 0
채택된 답변
华纳娱乐开户咨询【微8785092】
2023년 5월 20일
clear
global ist_tab
ist_tab = {[1,2,3],[4,5,6]};
ist_tab{1}
ist_tab{2}
abc(1)
function ab = abc(z)
global ist_tab
ab = ist_tab{z};
end
댓글 수: 0
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!