Borrar filtros
Borrar filtros

EXTRACT THE DISPLAYED COLUMN VECTORS INTO TABLE AND .CSV FILE

1 visualización (últimos 30 días)
Hi everyone, I want to extract all the output numbers into a .csv table.
A = table2array(Output)
A(1,:) = [] %delete first row of the double column
for i = 1:20
B = A(:,i);
x = unique(B);
N = numel(x);
count = zeros(N,1);
for k = 1:N
count(k) = sum(B==x(k));
end
disp([ x(:) count ]);
end
I get 2 errors:
1) For the """"disp([ x(:) count ]);"""" I only get in the output the numbers 1 and 0 of the last column of the tabe A, it doesn't maintain the columns before.
2) How should I write the script line in order to get a table and a .csv at the end for the """count""" column vectors displayed??
Thank you a lot in advance for your help guys!!
  5 comentarios
Myke Ziz
Myke Ziz el 2 de En. de 2020
Editada: Myke Ziz el 2 de En. de 2020
Where should I insert it exactly on the script because nothing change in my count table, when I tried to insert it.
I continue to get only the results of 1 column, the last one calculated.
for i = 1:20
B = A(:,i); %check only the first column
x = unique(B);
N = numel(x);
count = zeros(N,1);
for k = 1:N
count(k) = sum(B==x(k));
end
disp([ x(:) count ]);
end
Thank you a lot!
Best
M. Z.
Walter Roberson
Walter Roberson el 2 de En. de 2020
for i = 1:20
B = A(:,i);
x = unique(B);
N = numel(x);
for k = 1:N
count(x(k)+1, 1) = x(k);
count(x(k)+1, k+1) = sum(B==x(k));
end
end
disp(count)
This relies on the values in A being non-negative integers.

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 2 de En. de 2020
count1 = sum(A(:,1:20));
count0 = size(A,1) - count1;
count = [0 count0; 1 count1];

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by