Help Defining Variable Contained Within Summation Notation, and Using this Variable for Plot

1 view (last 30 days)
Hi all,
I am having trouble defining and using a variable in my code. In my code (shown below), I would like to establish a variable "t" that varies from 0 to 1e6, only containing integer values. Therefore, I would like my SumFe56 term to be a function that finds the sum from n=1 to n=1e7 for t=0, and then from n=1 to n=1e7 for t=1, and so on, until my code provides values for SumFe56 from n=1 to n=1e7 for t=1e6. I would then like to use the SumFe56 function in a larger function, BulkFe56, before finally making a plot that shows BulkFe56 values on the y-axis, and t on the x-axis, with the t values varying on this plot from t=0 to t=1e6. Can anyone please tell me the code that would be capable of doing this?
Here is my code, currently:
n = 1:1e7;
t = 0:1e6;
r = .002;
DFe56 = 1e-12;
SumFe56 = sum((1./n.^2).*exp(-n.^2*pi^2*DFe56*t/r^2));
BulkFe56 = (20*.9175)+((6*.9175*(9-20))/pi^2)*SumFe56;

Accepted Answer

fred  ssemwogerere
fred ssemwogerere on 11 Feb 2020
Hello, you could use nested for loop. But i envision this running into an "Out of memory" problem sheerly based on the length of "n" and "t".

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!