Extracting data from the original data set
12 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
sam moor
am 14 Nov. 2016
Kommentiert: Walter Roberson
am 14 Nov. 2016
I have a data file named roof-disp.out attached below. 1st column data refers to time and all other columns refers the corresponding distance. Now I want to extract the data for 0.02,0.04,0.06,...60.00 sec (at a difference of 0.02) from 1st column and corresponding distances. Is there a way to extract data from the original data for a particular values? Your answer is highly appreciated. Thank you.
Akzeptierte Antwort
Star Strider
am 14 Nov. 2016
Once again, the easiest way is to interpolate it:
fidi = fopen('sam moor rd.txt','rt');
Dcell = textscan(fidi, repmat('%f',1,9), 'CollectOutput',1, 'Delimiter',' ');
D = cell2mat(Dcell);
L = size(D,1);
t = D(:,1);
q = length(t > 0)/L;
ti = 0 : 0.02 : max(t); % Interpolation Vector
Di = interp1(t, D(:,2:end), ti, 'linear'); % Interpolated Data
rd_new = [ti' Di]; % Complete Interpolated ‘rd’ Matrix
3 Kommentare
Star Strider
am 14 Nov. 2016
I’d forgotten you were starting at 0.02 rather than 0.00.
This works:
fidi = fopen('sam moor rd.txt','rt');
Dcell = textscan(fidi, repmat('%f',1,9), 'CollectOutput',1, 'Delimiter',' ');
D = cell2mat(Dcell);
L = size(D,1);
t = D(:,1);
ti = 0.02 : 0.02 : max(t); % Interpolation Vector
Di = interp1(t, D(:,2:end), ti, 'linear'); % Interpolated Data
rd_new = [ti' Di]; % Complete Interpolated ‘rd’ Matrix
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Interpolation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!