How to call a function file into a script file?
이전 댓글 표시
In my project i've to extract the values of some variables from different function files of MATPOWER. I need to calculate some values using these variables in a script file for simplicity. I have tried [out1,out2,..]=fhandle(in1,in2,...) and @function name to access the functions inside the script file.But it is showing error that the input variable is undefined. Please provide me a solution as soon as possible.
답변 (1개)
Image Analyst
2013년 9월 22일
Just turn your script into a function by adding one line at the top, and you can get it all done in a single m-file. For example in test.m:
function test
a = 42;
out = MyFunction(a)
function result = MyFunction(inputValue)
result = inputValue * 100;
The "function test" line was all you had to add to the existing script.
댓글 수: 6
Maha
2013년 9월 22일
Maha
2013년 9월 22일
Image Analyst
2013년 9월 22일
How are you calling it? You can attach your file now, you know. Use the paper clip icon.
Maha
2013년 9월 22일
Maha
2013년 9월 22일
Image Analyst
2013년 9월 22일
Well you didn't define x before you passed it to a function. How do you think it's supposed to know what x is if you never told it???
카테고리
도움말 센터 및 File Exchange에서 Software Development에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!