Azzera filtri
Azzera filtri

determining the data of a repeated period from a single file.

3 visualizzazioni (ultimi 30 giorni)
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

Risposte (1)

Image Analyst
Image Analyst il 7 Mag 2024
Try conv
y = 1:8
y = 1x8
1 2 3 4 5 6 7 8
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
out = conv(y, [1,1]/2, 'full');
out = out(2:end-1)
out = 1x7
1.5000 2.5000 3.5000 4.5000 5.5000 6.5000 7.5000
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
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 Commenti
Image Analyst
Image Analyst il 8 Mag 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
Image Analyst il 8 Mag 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.

Accedi per commentare.

Categorie

Scopri di più su Data Import and Analysis in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by