# creating a vector where each element needs to be calculated before hand

1 visualización (últimos 30 días)
Douglas Brenner el 29 de Dic. de 2018
Respondida: dpb el 29 de Dic. de 2018
Can I creat Z in a single statement which doesn't require explicit calculation of each element or should I just use a loop?
Z = [ A*exp(B*X(1)), A*exp(B*X(2)), A*exp(B*X(3)), A*exp(B*X(4)) ...
, A*exp(B*X(5)), A*exp(B*X(6)), A*exp(B*X(6)) ];
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

dpb el 29 de Dic. de 2018
If X is a vector of numel(X) = 6, then
Z=A*exp(B*X);
if A,B are constants; otherwise it depends on what they are and what is the end result wanted...if they're both also vectors of same shape as X, then
Z=A.*exp(B.*X);
for element-wise multiplication. From the Q? it doesn't sound like you want/intend matrix multiplication, but that's doable, too, if that were to the desired result and have commensurately-sized Arrays/Vectors for conformant product dimensions.
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by