How do i write the following mathematical equation in MATLAB
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have written the following mathematical equation in matlab

as
F = 1/(abs(M)*abs(N))*(sum(sum(abs(SM(i,j)),j,1,abs(N)),i,1,abs(M)));
where F = sigma
I get the following error when i run it.
Error using sum
Too many input arguments.
Error in test_eg2 (line 23)
F = 1/(abs(N)*abs(G))*(sum(sum(abs(Pop(i,j)),j,1,abs(G)),i,1,abs(N)));
Thanks in advance
0 comentarios
Respuestas (2)
Walter Roberson
el 22 de Jul. de 2016
sum() must be given a list of values to total. sum() cannot be passed a variable of summation like you tried to use. sum() is "add these definite and fully pre-computed elements".
You might be tempted to look in the Symbolic Toolbox at symsum() which does accept variables of summation. However, symsum() has the limitation that the variable of summation cannot be used to index a vector or array.
4 comentarios
Walter Roberson
el 23 de Jul. de 2016
As I wrote "symsum() has the limitation that the variable of summation cannot be used to index a vector or array"
I am not sure which you are asking about for returning an integer data type. If you are asking about sum() then you can use the 'native' option; see http://www.mathworks.com/help/matlab/ref/sum.html#inputarg_outtype in order for the output to be the same data type as the input.
Ver también
Categorías
Más información sobre Calculus en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!