pcode always complains "Input argument is undefined."

조회 수: 1 (최근 30일)
Jinghua Cao
Jinghua Cao 2013년 11월 15일
편집: Walter Roberson 2013년 11월 15일
I tried it both in windows and unix, and I just dont understand why it happens. I have a function in its file.
% Beginning of file
function [MarginPOR] = creditFunc_prod1 ( Notional , MaxNotional )
%Linearly interpolate the probability of loss and stressed loss greater than 0
display('Using the OFFICIAL UNIX PRODUCTION creditFunc...');
MarginPOR = Notional + MaxNotional;
end
% End of file
Then I do this two,
>> pcode(creditFunc_prod1, '-inplace');
Using the OFFICIAL UNIX PRODUCTION creditFunc...
??? Input argument "Notional" is undefined.
Error in ==> creditFunc_prod1 at 7
MarginPOR = Notional + MaxNotional;
>> a= creditFunc_prod1(1,2)
Using the OFFICIAL UNIX PRODUCTION creditFunc...
a =
3
>>
If someone can help me understand why this happens, it will be really great.

답변 (2개)

Jinghua Cao
Jinghua Cao 2013년 11월 15일
ok, i wait wait wait and figured out myself. matlab documentation is wrong. here is what is in this document, http://www.mathworks.com/help/matlab/ref/pcode.html
"...pcode(fun) encrypts the code in fun.m and produces a file called fun.p, known as a P-file. ..."
In fact, this fun has to be a string of directory or full file name,
>> modeldev = '/home/jincao/pcodedir/';
>> pcode(modeldev,'-inplace');
this worked.

Kelly Kearney
Kelly Kearney 2013년 11월 15일
편집: Kelly Kearney 2013년 11월 15일
The documentation is fine. However, the fun input is supposed to be the file name:
pcode('creditFunc_prod1', '-inplace');
Note the quotes around the first argument. As you were calling it, Matlab interpreted the first argument not as the name of the function but as a call to the function, and tried to run it as presented, with no arguments. That leads to the error.
So it's not pcode that's complaining, but your own function.
  댓글 수: 1
Jinghua Cao
Jinghua Cao 2013년 11월 15일
to people who knows how to use this function, it is piece of cake. But to people who has never use this function before,
this line is just misleading, "...pcode(fun) encrypts the code in fun.m and produces a file called fun.p, known as a P-file. ..."
anyone reads this line will do this,
pcode(fun);

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

카테고리

Help CenterFile Exchange에서 Debugging and Analysis에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by