Error using variable in a function with trial version
显示 更早的评论
Hello,
I have a problem using my function Selection Sept. It told me that i use date as a function or a command but i don't know where. Why can't I name it in my script, use it in my function and then use it in my script again ? It worked on my friend computer who don't have the trial version but i do and on mine in doesn't work...
Thank you very much
采纳的回答
更多回答(1 个)
dpb
2017-5-13
function [matrice] = SelectionSept (matrice)
for i = length(date):-1:1;
...
date isn't defined in your function excepting as the builtin Matlab function
>> which date
C:\ML_R2014b\toolbox\matlab\timefun\date.m
because functions have their own context and the array date you created in the script isn't passed to the function.
It would behoove you to not use builtin function names in general; confusion reigns when alias something this way.
While I do NOT recommend it; the code above would function if the sundtion were defined to use date as the argument; then it would become associated with the A array passed internally. BUT, do NOT do this; use some other variable name other than DATE!!!
类别
在 帮助中心 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!