Extracting data from the original data set

조회 수: 23 (최근 30일)
sam moor
sam moor 2016년 11월 14일
댓글: Walter Roberson 2016년 11월 14일
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.

채택된 답변

Star Strider
Star Strider 2016년 11월 14일
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
sam moor
sam moor 2016년 11월 14일
something is wrong.. in a original data for time 0.02 the corresponding distance is -0.00864 (for your reference I only compare last column distance data) but for rd_new data for time 0.02 the corresponding distance was -0.0017 ( last column data). So something is wrong
Star Strider
Star Strider 2016년 11월 14일
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

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by