Percentage from two text file and send to axes in GUI.
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hello all. I have some problem here. How can i calculate similarity percentage from two text file then send it to one of my axes in GUI ? Here i attach my text file. In my text file only have 0 and 1 only. i try to use this code but it calculate the difference by line only. I want to store how many 0 and 1 i have then make the percentage of it. after that send the result to the axes in my GUI. Thanks guys.
visdiff('testa.txt', 'test1.txt', text);
0 Commenti
Risposte (2)
Geoff Hayes
il 28 Nov 2014
Akmal - if we assume that your two commas separated data files are of the same size (identical number of rows and columns), then we can use csvread to read the data from each into two different matrices
X = csvread('test2.txt');
Y = csvread('test3.txt');
Now, find those matrix indices that correspond to differences between the two
diffIdcs = find(X~=Y);
So now you have a list of differences (from which you can determine which indices of X and Y correspond to zeros and ones), and you can determine a percentage difference as
diffPercent = numel(diffIdcs)/numel(X);
11 Commenti
Geoff Hayes
il 3 Dic 2014
Akmal - please include the error message. What is your intent behind using evalc, just to write some text?
Thorsten
il 2 Dic 2014
Read the text files. Make sure you have the right names (you provide files test2.txt and test3.txt but use different files testa.txt and test2.txt in your code)
a2 = csvread('testa.txt');
a3 = csvread('test1.txt');
Compute the difference
D = abs(a2 - a3);
To show the difference image, use
imshow(D)
To display the percentage of '1's in D
perc = numel(find(D == 1))/numel(D)*100;
disp(['Pixels that differ: ' num2str(perc) '%'])
Vedere anche
Categorie
Scopri di più su LaTeX in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!