Info
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
importing text and integers using textscan and using in a matrix
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Image Analyst
el 25 de Jul. de 2012
Editada: Image Analyst
el 25 de Jul. de 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 comentarios
Image Analyst
el 25 de Jul. de 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?
La pregunta está cerrada.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!