필터 지우기
필터 지우기

how can i add 1-40,41-80, 81-120 and so on till 14000 datapoints which is in a text file?

조회 수: 3 (최근 30일)
sir....i have a text file which consist of 14000 rows and 2 columns.... i have to add the 40 points each till 14000 data... means 1-40 , 41-80, 81-120 and so on... what should i do for that???

채택된 답변

Walter Roberson
Walter Roberson 2014년 2월 13일
You have two columns, so
squeeze( sum( reshape(YourData, 40, [], 2) ) )
  댓글 수: 7
Ruby
Ruby 2014년 2월 15일
편집: Walter Roberson 2014년 2월 15일
clc;
clear all;
close all;
fid = fopen('filename.txt');
datacell= textscan(fid,'%f%f%f%*[^\n]',...
'delimiter','\t');
fclose(fid);
A = datacell{2};
B=datacell{3};
C=A-B;
datacell=rand(14000,2);
squeeze( sum( reshape(datacell, 40, [], 2) ) );
by using this error comes like..
Error using reshape
Product of known dimensions, 80, not divisible into total number of elements, 3.
Ruby
Ruby 2014년 2월 15일
편집: Walter Roberson 2014년 2월 15일
fid = fopen('filename.txt');
datacell= textscan(fid,'%f%f%f%*[^\n]',...
'delimiter','\t');
fclose(fid);
A = datacell{2};
B=datacell{3};
C=A-B;
t=0.0005:0.0005:0.065;
A1= squeeze( sum( reshape(A, 40, [], 1) ) );
B1=squeeze( sum( reshape(B, 40, [], 1) ) );
C1=A1-B1;
subplot(3,1,1);
stem(C1);
b=[0.69977431651797461 -0.1814575955924495 1.4113120181091672 -0.18145759559244945 0.69977431651797473];
a=[1 -0.21440197757618362 1.3190484139225416 -0.148513213608716 0.491812237222576];
y =filter(b,a,C1);
subplot(3,1,2);
stem(y);
d=[0.0000089848614639706426 0.0000035939445855882617 0.0000053909168783823964 0.0000035939445855882685 0.00000089848614639706807]
e=[1 -3.8358255406473472 5.5208191366222277 -3.5335352194630145 0.8485559996647685]
z=filter(d,e,C1);
subplot(3,1,3);
stem(z);
code is working... im using two filters here... notch and low pass filter..i have to find the statistics of the plot.... standard deviation and mean... what i should do???

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

추가 답변 (1개)

Jos (10584)
Jos (10584) 2014년 2월 13일
In cases when the total number of elements is not divisible by the size of the smaller groups, and reshape cannot be used, this trick with accumarray may be useful:
V = 1:10 ;
n = 3 ;
rem(numel(V),n) % :-(
ix = floor((0:numel(V)-1)/3) ;
R = accumarray(ix, V ,@sum)

카테고리

Help CenterFile Exchange에서 Correlation and Convolution에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by