Excelからデータを読み込み判別するコードを書きたい
Show older comments
Excelファイル「input.xlsx」を読み込み、そのデータの各値(Zp1、Zr1、Zp2、Zr2)を使用して条件を満たす列だけ抽出・出力するコードを書きたいです。
とりあえず、自分で書いてみたコードは以下です。
clear
n=3;
%%Excelファイルを読み込みたい
%%1番上の列から順番に以下の条件式に当てはめていく
%%%条件式%%%
P1= rem(Zr1,n)/n;
P2= rem(Zr2,n)/n;
np= n*gcd(Zp1,Zp2);
P11=zeros(np-1,1);
P22=zeros(np-1,1);
for i0=0:(np-1)
P11(i0+1)=(rem(i0*Zp1,np))/np;
P22(i0+1)=(rem(i0*Zp2,np))/np;
end
P_1= P1==P11;
P_2= P2==P22;
A_P1=find(P_1);
A_P2=find(P_2);
if isempty(A_P1)==1 || isempty(A_P2)==1
continue
end
A_P=zeros(length(A_P1),length(A_P2));
for i=1:length(A_P1)
for ii=1:length(A_P2)
A_P(i,ii)=A_P1(i)==A_P2(ii);
end
end
AA_P=find(A_P);
if isempty(AA_P)==1
continue
end
%%条件式を全て満たせば、その列を抽出し出力
初心者で、ぐちゃぐちゃでごめんなさい…
ご助言頂けますと幸いです。
Accepted Answer
More Answers (0)
Categories
Find more on スプレッドシート in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!