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;
fid = fopen(FILE);
Data=textscan(fid, '%f %f %f %f %f %f %f', 'delimiter', ',');
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);
segment_counter = segment_counter + 1;

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.


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