Large dataset in loop and save results in a variable
Show older comments
I have a large dataset. where I have 25million rows, I will be using 1-250,000, 1-500,000 and so on. I wrote the code, but the vaiable in the dielectricconstant is not saving properly. I have the below code, I think its just need a little tweak.
clc
clear all
T= 298.5; % temperature
Kb= 1.38065E-23; %Boltzman's Constant
e0= 8.85418*10^(-12); % permittivity in vacuum
e=(1.603*(10^-19))^2; % charge of electron
vol = 35.627171 * 35.627171 * 35.627171*10^(-30);
M = importdata('Trial-1-SPCE.dipole.Pw');
n = length(M); % number of rows
%A = M(1:2:end,:); % odd matrix--Dipole moment matrix
for n = 250000:250000:25000001
DielectricConstant = [];
for i = 1:100
A = M(1:n,:);
P = [A(:,3)+ A(:,4)+ A(:,5)];
Q= (mean(P))^2; %ensemble average square
P1= [A(:,3).^2+ A(:,4).^2+ A(:,5).^2];
Q1= (mean(P1)); %mean of square of dipole moment
MM= Q1-Q;
scale = e*(10^(-20))/(3*e0*Kb*T*vol);
DielectricConstant(i)= MM*scale;
end
end
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!