[英]matlab error: variable 'cell' is used but might be unset : matlab thinks function name is variable name
我在matlab中有一個函數,其開始如下:
function [W,Y] = myfun(L,nit)
W = cell(L,1);
x = cell(L+1,1);
...
因此,將W
和x
初始化為長度為L
單元格數組,然后在函數主體中繼續對它們進行實際處理。 但是,matlab的編輯器在第一次使用該消息的cell
下面有紅色的花樣線:
variable 'cell' is used but might be unset
如果我嘗試在主腳本中調用該函數,則會收到錯誤消息:
"cell" previously appeared to be used as a function or command, conflicting
with its use here as the name of a variable.
A possible cause of this error is that you forgot to initialize the
variable, or you have initialized it implicitly using load or eval.
而且我不明白為什么matlab認為我將cell
稱為變量的名稱。 我可以執行任一行
W = cell(L,1);
x = cell(L+1,1);
在此特定功能之外,並且它們按預期工作。 我已經在其他函數中創建了單元格數組,而沒有出現任何錯誤。 如果我使用命令
exist cell
我得到的答案是5,表明該cell
仍然是內置函數。 所以我很困惑。
我有同樣的問題。 原來,我在函數的后面有很多錯字,我叫cell而不是變量:
function [conn] = myfun(nn)
conn = cell(nn,1);
.
.
.
conn{i} = unique( cell{i} );
代替 :
conn{i} = unique( conn{i} );
造成錯誤的原因。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.