MATLAB Answers

## how to create symbolic function?

Asked by Michal Kvasnicka

### Michal Kvasnicka (view profile)

on 30 Oct 2017
Latest activity Edited by Michal Kvasnicka

### Michal Kvasnicka (view profile)

on 30 Oct 2017
Accepted Answer by Michal Kvasnicka

### Michal Kvasnicka (view profile)

I need to transform the following function to the symbolic form to evaluate it with arbitrary precision.
Z(N,Thetas) = prod((1 - exp(-(N:-1:2).*Thetas))./(1 - exp(-Thetas)),2)
where Thetas is matrix M x N-1 of the positive real numbers. So the expected result is vector Z (M x 1). I am not able to rewrite function Z to symbolic form and than evaluated it by vpa() command.
Any idea how to effectively solve it?

#### 0 Comments

Sign in to comment.

## 1 Answer

Answer by Michal Kvasnicka

### Michal Kvasnicka (view profile)

on 30 Oct 2017
Edited by Michal Kvasnicka

### Michal Kvasnicka (view profile)

on 30 Oct 2017
Accepted Answer

function Z=symZ(N,Thetas,Ndigit)
Thetas = sym(Thetas);
Zsym = prod((1 - exp(-(N:-1:2).*Thetas))./(1 - exp(-Thetas)),2);
Z = vpa(Zsym,Ndigit);
end

#### 0 Comments

Sign in to comment.