Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

How to write this equation within Matlab?

  1. Aug 12, 2007 #1
    The problem statement, all variables and given/known data
    Hi, guys. I've been reading a paper including some equations. Now, I'd like to write one equation as codes in Matlab. The equation is as following:

    E{T} = (ln(v_max / v_min) / v_max - v_min) * E{L}

    where E{T} is the expected value of transition time and E{L} is the expected value of transition distance. Also, v_max and v_min mean the maximum speed and the minimum speed, respectively. Note that the speed is a uniform speed distribution within [v_min, v_max].

    Thanks in advance.
     
    Last edited: Aug 12, 2007
  2. jcsd
  3. Aug 13, 2007 #2

    chroot

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    Are all these quantities scalars?

    - Warren
     
  4. Aug 13, 2007 #3
    Yes, they are all scalar values. However, E{T} and E{L} can be vectors.
     
  5. Aug 13, 2007 #4

    chroot

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    Then they aren't all scalars.

    Do something like this

    Code (Text):
    EL = [ 1 2 3 ]
    v_min = 1
    v_max = 2

    ET = (log(v_max / v_min) / (v_max - v_min)) * EL
    - Warren
     
  6. Aug 13, 2007 #5
    Thanks for your kind reply. Could you provide one more? The speed values (v_max and v_min) are in a uniform speed distribution within [v_min, v_max].

    How do I write that in Matlab? Shall I just use rand() ? (I just want to confirm from others because I'm not an export within Matlab)

    Thanks in advance.
     
  7. Aug 13, 2007 #6

    chroot

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    You're aware that Matlab has excellent built-in help, right?

    Code (Text):

    >> help rand
    ...
    Generate uniform values from the interval [a, b].
               r = a + (b-a).*rand(100,1);
     
    If you just want one random number, use:

    Code (Text):
    v = v_min + (v_max - v_min) * rand();
    - Warren
     
  8. Aug 13, 2007 #7
    Thanks. As you mentioned, Matlab has an excellent help system and I know about that. Sorry, I might annoy you (I just want to get the certain reply from Matlab experts).

    Anyway, thanks again!
     
  9. Jan 18, 2012 #8
    hw to design current steering binary weighted dac in matlab

    Hi, anybody can u pls suggest hw to design the dac using binary weighted current steering method in matlab.

    thanks
     
  10. Jan 31, 2012 #9
    How to write this code in Matlab?

    M0=100;
    var0=100;

    for i=1:478
    for j=1:448
    if(temp(i,j)>M)
    G(i,j)=M0+sqrt(double((var0*power((temp(i,j)-M),2))/V));
    else

    G(i,j)=M0-sqrt(double((var0*power((temp(i,j)-M),2))/V));

    Where temp(i,j) is an matrix. This code is not working. I am getting the values of G as 100. Please help me with the correct code. I am new to matlab.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?



Similar Discussions: How to write this equation within Matlab?
Loading...