Matlab Symbolic toolbox question, 'exp' and vector elements

  • #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.
 

Answers and Replies

Related Threads on Matlab Symbolic toolbox question, 'exp' and vector elements

  • Last Post
Replies
5
Views
3K
  • Last Post
Replies
3
Views
3K
Replies
8
Views
1K
Replies
2
Views
2K
  • Last Post
Replies
1
Views
91
Replies
2
Views
3K
Replies
1
Views
19K
Replies
14
Views
7K
Replies
4
Views
816
Replies
2
Views
2K
Top