A command in the script runs in the Command window but not in the script

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???

답변 (1개)

Jan
Jan 2017년 10월 3일
편집: Jan 2017년 10월 3일

0 개 추천

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.

카테고리

도움말 센터File Exchange에서 Data Type Conversion에 대해 자세히 알아보기

질문:

2017년 10월 3일

편집:

Jan
2017년 10월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by