determining the data of a repeated period from a single file.
Dear Folks,
I have modified a code in matlab to make computation over a repeated period in a single file, in which the computations repeated over every 500 steps. Please, could you help me in modifing the script to take the average of the x between each two x’s for every 500 steps. This means that the x_average will have an (N-1) values.
clc; clear all;
FILE=’ENZUVH.csv’;
fid = fopen(FILE);
Data=textscan(fid, ‘%f %f %f %f %f %f %f’, ‘delimiter’, ‘,’);
fclose(fid);
xx=Data{1};
yy=Data{2};
zz=Data{3};
u=Data{4};
v=Data{5};
h=Data{6};
NN=length(Data{1});
%==================================================
step_size = 500; N=500;
x = zeros(N,2);
y = zeros(N,2);
cx = zeros(N,2);
sx = zeros(N,2);
UU = zeros(N,2);
VV = zeros(N,2);
hh = zeros(N,2);
segment_counter = 1;
for segment_start = 1:step_size:NN
for j = 1:N
for i = segment_start:min(segment_start+step_size-1, NN)
x(j,segment_counter) = xx(j);
y(j,segment_counter) = yy(j);
ele(j,segment_counter) = zz(j);
UU(j,segment_counter) = u(j);
VV(j,segment_counter) = v(j);
hh(j,segment_counter) = h(j);
end
end
segment_counter = segment_counter + 1;
endDear Folks,
I have modified a code in matlab to make computation over a repeated period in a single file, in which the computations repeated over every 500 steps. Please, could you help me in modifing the script to take the average of the x between each two x’s for every 500 steps. This means that the x_average will have an (N-1) values.
clc; clear all;
FILE=’ENZUVH.csv’;
fid = fopen(FILE);
Data=textscan(fid, ‘%f %f %f %f %f %f %f’, ‘delimiter’, ‘,’);
fclose(fid);
xx=Data{1};
yy=Data{2};
zz=Data{3};
u=Data{4};
v=Data{5};
h=Data{6};
NN=length(Data{1});
%==================================================
step_size = 500; N=500;
x = zeros(N,2);
y = zeros(N,2);
cx = zeros(N,2);
sx = zeros(N,2);
UU = zeros(N,2);
VV = zeros(N,2);
hh = zeros(N,2);
segment_counter = 1;
for segment_start = 1:step_size:NN
for j = 1:N
for i = segment_start:min(segment_start+step_size-1, NN)
x(j,segment_counter) = xx(j);
y(j,segment_counter) = yy(j);
ele(j,segment_counter) = zz(j);
UU(j,segment_counter) = u(j);
VV(j,segment_counter) = v(j);
hh(j,segment_counter) = h(j);
end
end
segment_counter = segment_counter + 1;
end Dear Folks,
I have modified a code in matlab to make computation over a repeated period in a single file, in which the computations repeated over every 500 steps. Please, could you help me in modifing the script to take the average of the x between each two x’s for every 500 steps. This means that the x_average will have an (N-1) values.
clc; clear all;
FILE=’ENZUVH.csv’;
fid = fopen(FILE);
Data=textscan(fid, ‘%f %f %f %f %f %f %f’, ‘delimiter’, ‘,’);
fclose(fid);
xx=Data{1};
yy=Data{2};
zz=Data{3};
u=Data{4};
v=Data{5};
h=Data{6};
NN=length(Data{1});
%==================================================
step_size = 500; N=500;
x = zeros(N,2);
y = zeros(N,2);
cx = zeros(N,2);
sx = zeros(N,2);
UU = zeros(N,2);
VV = zeros(N,2);
hh = zeros(N,2);
segment_counter = 1;
for segment_start = 1:step_size:NN
for j = 1:N
for i = segment_start:min(segment_start+step_size-1, NN)
x(j,segment_counter) = xx(j);
y(j,segment_counter) = yy(j);
ele(j,segment_counter) = zz(j);
UU(j,segment_counter) = u(j);
VV(j,segment_counter) = v(j);
hh(j,segment_counter) = h(j);
end
end
segment_counter = segment_counter + 1;
end numerical integration, data, manikanta aditya MATLAB Answers — New Questions