How do i write the following mathematical equation in MATLAB
    4 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
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 Commenti
Risposte (2)
  Walter Roberson
      
      
 il 22 Lug 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 Commenti
  Walter Roberson
      
      
 il 23 Lug 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.
Vedere anche
Categorie
				Scopri di più su Calculus in Help Center e File Exchange
			
	Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!