필터 지우기
필터 지우기

Undefined function or variable

조회 수: 2 (최근 30일)
Ahmad Badran
Ahmad Badran 2020년 10월 1일
댓글: Cris LaPierre 2020년 10월 2일
Hi
I am working on a simulation project, some output of the simulation will be as input for matlab functions,
inside the Matlab function there are variables which are defined in a mfile , but the problem every time I run the simulation I got the message "Undefined function or variable " which are defined in m.file
anyone know how this can be solve?

답변 (1개)

Cris LaPierre
Cris LaPierre 2020년 10월 2일
The question should be do the variables exist in the workspace at the time you want to use them? Having them defined in a separate file does not help. You need to run that script inside the function if you want the variables it defines to be available. Of course, that will only work if your m-file itself is a script and not a function.
  댓글 수: 2
Ahmad Badran
Ahmad Badran 2020년 10월 2일
so, How I can run the scripte inside the function ?
Cris LaPierre
Cris LaPierre 2020년 10월 2일
Scripts can be run by calling them by name, similar to a function. They just don't have any inputs. So if I had a script called vardef that defined my variables a and b, I could do this
...
vardef
x = b*sin(a);

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

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by