New to matlab. Trying to make a script to reorganize excel data

1 visualización (últimos 30 días)
Elise Isobel Alexander
Elise Isobel Alexander el 6 de Mayo de 2021
Respondida: David Hill el 6 de Mayo de 2021
Hello. I have an excel file that contains two columns, column one contains numbers and column two contains strings. I am trying to write some code that allows me to collect the number in the row that I given string is present. For example, for the string 'dog' I want to the program to look for every iteration of 'dog' and grab the number that is in the same row and place it in a column of a new excel file under the column header dog.
Any help is appreciated!
  1 comentario
Rik
Rik el 6 de Mayo de 2021
Break it into steps you can google or solve yourself.
You will very likely need xlsread, xlswrite and ismember. I don't immediately see why you would need any other function.
Have a read here and here. It will greatly improve your chances of getting an answer.

Iniciar sesión para comentar.

Respuestas (1)

David Hill
David Hill el 6 de Mayo de 2021
a=readcell('yourcellname');
b=unique(a(:,2));
newCell=b';
for k=1:length(b)
newCell(2,k)={a(ismember(a(:,2),b{k}),1)};
end

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by