MATLAB Answers

how to import a file from xls

1 view (last 30 days)
Niki
Niki on 30 Aug 2015
Answered: Star Strider on 30 Aug 2015
Hello, I am having difficulties to import a file from xls. I provide you with a part of mw data as follows:
262 268,5035949 272,5741509
262 264,3953307 271,695265
276 275,7568674 282,2664962
265 265,689301 266,2047494
261 262,3786524 262,7157746
263 264,2770077 263,9411982
264 269,5544951 265,8121476
270 268,95849 266,3144101
265 265,1169026 263,5498798
274 264,7772694 269,8253276
The data is like 3 columns but when I import it, it makes it 5 columns. Basically, I converted the xls files to txt file but still the same problem. Can someone comment on how to solve this problem?
Thanks

  0 Comments

Sign in to comment.

Answers (1)

Star Strider
Star Strider on 30 Aug 2015
One way of creating three columns from the five columns you imported:
data = randi(99, 10, 5); % Create Data
dstr = sprintf('%d\t%.0f.%.0f\t%.0f.%.0f\n', data'); % Create String From It
[D(:,1),D(:,2),D(:,3)] = strread(dstr); % Read As Numeric
The ‘D’ matrix is the output.

  0 Comments

Sign in to comment.

Sign in to answer this question.

Tags


Translated by