Check a column, if a condition is met use those value

조회 수: 20 (최근 30일)
sivalogan satchithanandamoorthy
sivalogan satchithanandamoorthy 2017년 6월 19일
편집: Jan 2017년 6월 19일
I have excel file containing cyclic data of 25 by 1000. Let say column 3 represent cycle. i was able to plot the data for all cycle. The problem is I am not sure how to plot for specific cycle. sample date could be: A=[1,2,1,4,5;6,7,1,9,10;11,12,1,14,15;16,17,2,19,20;21,22,2,24,25;26,27,2,29,30]
My question is how to chose date from other column when column 3 is specific cycle.(it could be 1, 2, 3 or 1 to 5 or 10 11 13).
Any help would ne much appricated

채택된 답변

KSSV
KSSV 2017년 6월 19일
A=[1,2,1,4,5;6,7,1,9,10;11,12,1,14,15;16,17,2,19,20;21,22,2,24,25;26,27,2,29,30] ;
%%pick cycle 1
c1 = A(A(:,3)==1,:)
%%pick cycle 2
c2 = A(A(:,3)==2,:)
  댓글 수: 1
Jan
Jan 2017년 6월 19일
편집: Jan 2017년 6월 19일
+1. And pick cycles 1 to 5:
c1_5 = A(A(:,3) >= 1 & A(:,3) <= 5, :)
or
c1_5 = A(ismember(A(:,3), 1:5), :)

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

추가 답변 (1개)

Guillaume
Guillaume 2017년 6월 19일
If all the cycles are the same length and all the samples from a cycle are together, as in your example, you would be better off reshaping your matrix as 3D, with the cycles in the 3rd dimension
A = reshape(A, cyclelength, size(A, 2), []); %where cyclelength is the length of a cycle
It is then trivial to plot any cycle:
hold on
for cyclenumber = 1 : size(A, 3)
plot(A(:, 1, cyclenumber)) %plot column 1 of cycles, for example
end

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by