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

plot axis based on a function found online

Asked by Locks on 29 Mar 2013

I found the following function:

http://www.mathworks.ch/support/solutions/en/data/1-216M68/index.html?product=ML&solution=1-216M68

what do I not to do to be able to save that function to my matlab and is there a way somebody else who hasen't downloaded that file is still able to see what it's doing?

0 Comments

Locks

Products

No products are associated with this question.

1 Answer

Answer by Walter Roberson on 29 Mar 2013

At the bottom of that page there is a header

Related Documents/Files:

below which there is a link for drawaxis.m . Click on that link to download the file. Put the file in a convenient location on your MATLAB path.

Anyone who wishes to execute your code will need a copy of the file. You could include it along with your code.

9 Comments

Locks on 29 Mar 2013

I tried to insert your code, but it doesn't word, here is the full code:

x  =[0:0.01:20]
  y1=blsprice(x,10,0.02,0.2,0.2)-blsprice(10,10,0.02,0.2,0.2)
  y2=max(x-10,0)-blsprice(10,10,0.02,0.2,0.2)
    plot(x,y1,'k',x,y2)

What do I need to change?

    xlabel('Stock Price at Maturity ($)');
    ylabel('Gain ($)');
    axis([8.5 11.5  -0.5 1]);
    set(gca,'xtick',9:0.5:11.5)
    y1L = get(gca, 'yLim');
    y1L(1) = min(0, y1L(1));
    y1L(2) = max(0, y1L(2));
    set(gca, 'yLim', y1L);
    annotation(gcf,'doublearrow',[0.515 0.515],[0.2 0.36])
    text(10.25,-0.2,'Time value')
    set(gca,'Box','off')
Walter Roberson on 30 Mar 2013

Are you getting an error message? I do not have the toolbox with blsprice() in it, so I cannot test your code.

Locks on 30 Mar 2013
x  =[0:0.01:20]
  y1=blsprice(x,10,0.02,0.2,0.2)-blsprice(10,10,0.02,0.2,0.2)
  y2=max(x-10,0)-blsprice(10,10,0.02,0.2,0.2)
    plot(x,y1,'k',x,y2)
      xlabel('Stock Price at Maturity ($)');
      ylabel('Gain ($)');
      axis([8.5 11.5  -0.5 1]);
      set(gca,'xtick',9:0.5:11.5)    
      annotation(gcf,'doublearrow',[0.515 0.515],[0.2 0.36])    
      text(10.25,-0.2,'Time value')    
      set(gca,'Box','off')

this code is perfectly working so I guess it can't be blsprice ()

could you tell me what I excatly ned to change in my code and where I have to place the new elements?

Walter Roberson

Contact us