Matlab Graphing

Discussion in 'Programmer's Corner' started by Cerkit, Mar 12, 2010.

  1. Cerkit

    Thread Starter Active Member

    Jan 4, 2009
    275
    3
    Hi. I need to graph the following functions in Matlab but I don't seem to be able to get the expected graph

    hbar=1.054e-34; %h/2pi [J.s]
    me=9.11e-31; %electron effective mass [Kg]
    L=0.2e-9; %Half of well width [m]
    V=75;
    E=0:1:75;

    X=sqrt(((V*1.6e-19)-(E*1.6e-19))/(E*1.6e-19));
    Y=tan(((sqrt(2*me*E*1.6e-19))/(hbar))*L);
    Z=-cot((((sqrt(2*me*E*1.6e-19))*L)/(hbar)));

    I am meant to have X intersecting Y at 1.8,16.9 and 46.05 and intersecting Z at 7.5,29.9 and 64.6. Any help will be much appreciated.

    Thanks
     
  2. johndoe45

    Member

    Jan 30, 2010
    364
    1
    you needed a . before the / in X equation. forgot why buy just do otherwise its division of vectors. don't want that, you want to divide each value in the array E.



    E=0:1:75;

    hbar=1.054e-34; %h/2pi [J.s]
    me=9.11e-31; %electron effective mass [Kg]
    L=0.2e-9; %Half of well width [m]
    V=75;

    X=sqrt(((V*1.6e-19)-(E*1.6e-19))./(E*1.6e-19));
    Y=tan(((sqrt(2*me*E*1.6e-19))/(hbar))*L);
    Z=-cot((((sqrt(2*me*E*1.6e-19))*L)/(hbar)));

    plot(E,X,E,Y,E,Z)
     
    Last edited: Mar 22, 2010
Loading...