MATLAB Answers

I am getting the following error in my code: "Unrecognized function or variable 'f'. " How do I correct this error? someone can help me in this TIA.

조회 수: 5(최근 30일)


dpb 2021년 7월 31일
편집: dpb 2021년 7월 31일
You're using f in line 1 while you don't define it until line 3.
Move line 1 to anywhere after but before use amp in line 11 -- I'd suggest it makes sense that it be line 10, the first calculation after all the inputs...
Code execution is purely linear -- just because the variable is defined somewhere in the code isn't enough; it must be defined in sequence of code execution before it is referenced.
Of course, calling a function that returns variables isn't strictly linear in execution in that the code in the function may be elsewhere in the function or another m-file or builtin, but the calling of the function must be in sequence such that any variables it defines (and returns) are available in order...
  댓글 수: 3
Walter Roberson
Walter Roberson 2021년 8월 1일
The point was to talk about why computer languages do not work the way the poster was expecting, so that the poster would better understand the difficulty.

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by