Eliminating and creating new data file

Hello all, I have data which has information for different events, each event has 5 row information. I just want to eliminate this data and delete all of 5 line for that event with respect to some criteria and to create new data file without eleminated data.
A = xlsread('example.xls');
M = cell(1, length(4:5:size(A,1))); %Preallocate M for speed
Miso = cell(1,length(4:5:size(A,1))); %Preallocate Miso for speed
isoratio = cell(1,length(4:5:size(A,1))); %Preallocate isoratio for speed
j = 1; q=1; v=1;
for i= 4:5:size(A,1)
Mrr=A(i,2)*10^A(i,1);
Mtt=A(i,4)*10^A(i,1);
Mpp=A(i,6)*10^A(i,1);
Mrt=A(i,8)*10^A(i,1);
Mrp=A(i,10)*10^A(i,1);
Mtp=A(i,12)*10^A(i,1);
%%%build the given full moment tensor%%%
M{j} = [Mrr Mrt Mrp; Mrt Mtt Mtp; Mrp Mtp Mpp];
Miso{q}=(trace(M{j}/3)*eye(3,3));
isoratio{v} = norm(Miso{q},'fro')/(norm(M{j},'fro'));
j = j + 1;
q = q + 1;
if isoratio{v} > 10e-17;
fprintf('isoratio > 10e-17 \n');
end
v = v + 1;
end
For example in this case I defined isoratio for each event, and the program should delete all 5 line information about that event and write 5 line information of each event with isoratio value bigger than 10e-17 to new xlsx or txt file.
Is there any advice for this code ? I attached data file to this post. Thanks in advance for your interest.

댓글 수: 2

Gökçe Öter
Gökçe Öter 2018년 6월 1일
편집: Gökçe Öter 2018년 6월 1일
Yes, but this one is not the same with the former one. In this case for loop is considered and calculation is the critical part to save new data file which I couldn't achieve :)

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

답변 (1개)

Jan
Jan 2018년 6월 4일
편집: Jan 2018년 6월 4일

1 개 추천

An advice:
Compare:
Mrr=A(i,2)*10^A(i,1);
Mtt=A(i,4)*10^A(i,1);
Mpp=A(i,6)*10^A(i,1);
Mrt=A(i,8)*10^A(i,1);
Mrp=A(i,10)*10^A(i,1);
Mtp=A(i,12)*10^A(i,1);
M{j} = [Mrr Mrt Mrp; Mrt Mtt Mtp; Mrp Mtp Mpp];
with
index = [2, 8, 10; 8, 4, 12; 10, 12, 6]; % Before the loop
M{j} = reshape(A(i, index), 3, 3) *10^A(i,1);
length(4:5:size(A,1)) is a waste of time. Use this once:
len = floor((size(A, 1) - 4) / 5) - 1

카테고리

도움말 센터File Exchange에서 Read, Write, and Modify Image에 대해 자세히 알아보기

제품

릴리스

R2017b

질문:

2018년 5월 31일

편집:

Jan
2018년 6월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by