Borrar filtros
Borrar filtros

how to write this range in Matlab?

1 visualización (últimos 30 días)
NMK
NMK el 21 de Jul. de 2016
Respondida: Steven Lord el 21 de Jul. de 2016
how do we write the following type of range in matlab:
∑_jϵN=m_nj
i.e. j lies in N.
Thanks.
  2 comentarios
Azzi Abdelmalek
Azzi Abdelmalek el 21 de Jul. de 2016
This is not clear
Walter Roberson
Walter Roberson el 21 de Jul. de 2016
It looks to me as if it might be the sum over those j that are elements of (N = m) to (N = n), with the term to be summed being j ?

Iniciar sesión para comentar.

Respuestas (2)

Walter Roberson
Walter Roberson el 21 de Jul. de 2016
I am going to guess that this is
sum(N(N >= m & N <= n))

Steven Lord
Steven Lord el 21 de Jul. de 2016
Use linear indexing.
% Generate sample data
x = (1:20).^2;
% Generate a set N over which to sum
N = randperm(20, 5)
% Compute the sum over the set N
sumXN = sum(x(N))
% Since the kth element of x is just k^2, check by summing N^2
% Use .^ to perform element-wise squaring
sumN2 = sum(N.^2)
sumXN and sumN2 should be the same.

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by