Info
Cette question est clôturée. Rouvrir pour modifier ou répondre.
importing text and integers using textscan and using in a matrix
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have a text file with 2 cols. Col one is text and col is integer. I want to import the two cols and then be able to manipulate the imported set, eg, randomize the order of the rows. I've tried textscan and xlsread but I cannot work with the imported data in matlab. for example, I have word1 3 word2 5 word3 5 . . . and want to randomize the order of the rows.
3 commentaires
Réponses (1)
Image Analyst
le 25 Juil 2012
Modifié(e) : Image Analyst
le 25 Juil 2012
Why don't you use dlmread()?
Demo to randomize rows:
% Generate sample data.
m = magic(6)
% Get a random order for the rows.
randomRows = randperm(size(m, 1))
% Extract rows in that random order into a new matrix.
randomized_m = m(randomRows, :)
7 commentaires
Image Analyst
le 25 Juil 2012
Can't you just use str2double to convert the string version of the numbers into double, and then use sort()? That's seems like the obvious procedure, so I'm sure you already tried that. So what happened when you tried it?
Cette question est clôturée.
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!