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

Matlab Symbolic toolbox question, 'exp' and vector elements

  1. Dec 22, 2011 #1
    I have a piece of code which near its end needs to do the following task: Given a vector V=(log(A),log(B),log(C)) that has been previously generated[I've used 'log' as opposed to ln here because the 'log' function in matlab is the natural logarithm], I need to find sum(A,B,C). NOT sum(log(A),log(B),log(C))=log(A*B*C), but sum(A,B,C). However, log(A),log(B) and log(C) are each large negative numbers (log(A)=-6126.9,log(B)=-4371.2,log(C)=-2942.1) When I use exp the results are rounded to zero. This is a problem, because the next step in the code is log(D), where D=sum(A,B,C), and log(0)=-Inf (I have a good reason for going from log to exp and back again). I can use the symbolic math toolbox to get the precision I need so that the results for using 'exp' are very small numbers instead of being rounded to 0. However, I don't know how to put this inside my code, i.e. when I type k=sym('exp(v(1,1))') in the matlab command window, it returns k=exp(v(1,1)) as opposed to the value 1.3217180682567377112866860751447*10^(-2661), which is what I get when I do k=sym('exp(-6126.9)'). How can I use sym('exp()') with a particular element of a vector so that I can put this in my code? I'm new to matlab, and if part of the problem is I'm trying to use a tool without understanding how it works, well, learning is exactly why I am at this forum. Thank you very much to anyone who has any advice.
     
  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted



Similar Discussions: Matlab Symbolic toolbox question, 'exp' and vector elements
  1. Matlab toolboxes (Replies: 3)

Loading...