A command in the script runs in the Command window but not in the script
Show older comments
Hi all, I’m trying to run a function. There is no problem/conflict between the function name and the script.m name, indeed the code runs of course. But, running line by line, in the section of the code:
seasonal=seasonal';
parameters=parameters';
execution=mexe;
CorrMatrix=corrmatr;
clear corrmatr
I find the message: Not enough input arguments. Error in script (line 36) seasonal=seasonal';
However the variable seasonal is in the workspace. Indeed, if I copy and paste the command in the Command Window, it runs. Can you help me, please???
Answers (1)
If there is a conflict between the names of a function and a variable, simply rename one of them. Sounds like a trivial solution.
If even Matlab is confused and the code behaves differently if run in the command window or inside a function, or script, or by "Evaluate section" in the editor - then you can expect, that a human reader will be confused also. This will impede debugging and maintaining the code. Using unique names is a good and reliable solution.
Categories
Find more on Data Type Conversion in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!