Comparing data in a spreadsheet
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
I have data that I need to compare. I am not sure how to code this in Matlab. So for instance, I have columns, A, B, and C as below.
A B C
5 1 2
4 2 3
3 3 4
2 4 5
1 5 3
. . .
. . .
. . .
. . .
How do I count and list all the 5s in A and show what the 5s in A listed for their B and C answers? For instance, for all the 5s in A: there are seven 1s, three 2s, etc in column B. And there are four 1s, eight 2s, etc, in column C that have 5s in A. And also show the sum.
0 Commenti
Risposte (1)
Image Analyst
il 9 Dic 2020
To find the numbers of each number in the first column of A, do this
counts = histogram(A(:, 1))
To find the rows with a particular number in the first column, do this:
mask = A(:, 1) == 2; % Find rows where first column is 2.
maskedA = A(mask, :); % Only those rows where first column = 2.
To count the count of each number in the other columns, do
countsB = histogram(maskedA(:, 2));
countsC = histogram(maskedA(:, 3));
If tthat doesn't work, give a full sample matrix, and your expected output.
Vedere anche
Categorie
Scopri di più su AI for Signals 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!