determining the data of a repeated period from a single file.
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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
0 commentaires
Réponses (1)
Image Analyst
le 7 Mai 2024
Try conv
y = 1:8
out = conv(y, [1,1]/2, 'full');
out = out(2:end-1)
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:
2 commentaires
Image Analyst
le 8 Mai 2024
Did you see my last comment where I said "If you have any more questions, then attach your data and code"? I'm not seeing 'ENZUVH.csv' attached. Did you just forget?
Image Analyst
le 8 Mai 2024
Your stepsize is 500 so it only does an interation for segment_start=1 and segment_start=501 and none of the values in between.
Voir également
Catégories
En savoir plus sur Data Import and Analysis dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!