Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

code does gives me an error message if I execute it with F5, but if I mark the full code and press F9, its working

Asked by Locks on 4 May 2013

Hi,

I have this code here:

S0=10
K=10
T=0.2
Tt=0.05
Vola=0.2
r=0.02
x=[0:0.001:20];
y1=blsprice(S0,K,r,T,Vola)-blsprice(x,K,r,Tt,Vola);
y2=blsprice(S0,K,r,T,Vola)-blsprice(x,K,r,T,Vola);
plot(x,y1,'k',x,y2)
xlabel('Stock Price ($)');
ylabel('Gain ($)');
axis([8 12  -1 0.5]);
set(gca,'xtick',8.5:0.5:12)
text(10.05,0.25,'Call short at t=t','color','k');
text(8.35,0.25,'Call short at t=0','color','b');
line([0 ; 12],[0 ; 0],'color','k')
%line([10 ; 10],[-1 ; 1],'color','k')
set(gca,'Box','off')

By selecting everything and pressing F9, it's working perfectly. However, if I press F5, I get this error message:

Undefined function 'delta_hedge_call_short_portfolio_t1_option' for input
arguments of type 'char'.

Do you have any idea what is not working here?

0 Comments

Locks

Products

No products are associated with this question.

1 Answer

Answer by Azzi Abdelmalek on 4 May 2013
Edited by Azzi Abdelmalek on 4 May 2013
Accepted answer

When you select your code then click f9 means your code is executed in the current folder, when you cick f5, it's executed from where the file is saved, maybe it could'nt find some functions

3 Comments

Locks on 4 May 2013

it must be the variables I define above:

S0=10
K=10
T=0.2
Tt=0.05
Vola=0.2
r=0.02
is there another way to do that?
Azzi Abdelmalek on 4 May 2013

I do not think, it 's caused by those constant, check if your m file and all the functions it is calling are in the same folder

Locks on 4 May 2013

I have pasted the whole code in a new script and it's working fine, no idea what the problem was, but thanks for your help

Azzi Abdelmalek

Contact us