Thursday 15 May 2014

How do you sum values inside a for loop in Matlab? -


I want to add acid to run the loop and then want to print the total value of all previous acidic values. My problem is just fine, it is currently printing only individual values, which is not acidic.

p> ans =

  2.1676  

This is my code

  pki = [7.7,3.9]; T = 2; N = 55; For i = 1: t; Acidic = Log 10 (1 / ((n-1) * (10 ^ -piki (I)))); Yoga (acidic) and  

edit - as Indicates, you do not need the t variable.

You do not have any semicolons on your line sum (acidic) , so MATLAB prints the result. But it seems that you have some other problems - acidic is a scaler, so the value is overwriting every time, maybe you want to do something like this:

  pki = [7.7,3.9] ; N = 55; Acidic = Log 10 (1 / ((n-1). * (10. ^ - pki)));  , . * , and .     operators. They tell MATLAB the element based on element conducting on the vectors. MATLAB tells print out the last  disp  line output value. 


No comments:

Post a Comment