New to matlab. Trying to make a script to reorganize excel data
1 view (last 30 days)
Show older comments
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!
Answers (1)
David Hill
on 6 May 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
0 Comments
See Also
Categories
Find more on Spreadsheets in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!