Calling an imported variable into a function
이전 댓글 표시
I have imported a numerical matrix of size 336*1, and am trying to use it within a function. When i try to call it without any additional codes, it gives me a warning to ' Explicitly initialize the variable' and am not sure how to do that without passing it as a parameter in the function. I mainly don't want to pass it as a parameter as i am working with optimization and the non-linear constraints function works only with one variable inputy.
Do let me know how i could potentially call it within a function
댓글 수: 3
Stephen23
2020년 7월 4일
"I mainly don't want to pass it as a parameter as i am working with optimization and the non-linear constraints function works only with one variable inputy"
That is exactly what function parameterization is for:
Simply add the required input arguments to your function definition, and then call it using an anonymous function, just like the documentation shows.
Ebin Daniel
2020년 7월 6일
Stephen23
2020년 7월 6일
"Unrecognized function or variable 'nlin'."
That error message is quite clear: where is nlin defined? Why do you think that MATLAB should know what it is?
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Write Constraints에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!