CSVから取り込んだデータのisequalを用いた等価性の確認
Show older comments
2つのCSVファイルが等しいものかどうかを確認するためのプログラムを作成し、どの部分が異なるのかを確認しようと考えています。
そこでisequalを用いて等価性を判別した後に、IF文を用いて該当箇所を検索するコードを作成しました。
実行したところisequalがFalseになったため、IF文を用いて差分を検索しましたが、見つかりませんでした。
コードは以下の通りです。(添付の二つのCSVファイルの差分を検出しようとしています。)
clear
Ts=1;
filename = 'sys_out.csv';
listing = dir(filename);
value = getfield(listing, 'bytes');
switch value
case 0
sprintf('sys_outなし');
otherwise
IN=csvread(filename);
end
filename = 'test.csv';
listing = dir(filename);
value = getfield(listing, 'bytes');
switch value
case 0
sprintf('testなし');
otherwise
IDEAL=csvread(filename);
end
tf = isequal(IN,IDEAL)
switch tf
case 0
n = size(IN);
Table = zeros(n(1,1),2);
for a = n(1,1)
if IN(n(1,1),1) == IDEAL(n(1,1),1)
Table(n(1,1),1) = 0;
else
Table(n(1,1),1) = 1;
end
if IN(n(1,1),2) == IDEAL(n(1,1),2)
Table(n(1,1),2) = 0;
else
Table(n(1,1),2) = 1;
end
end
case 1
end
k = find(Table)
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!