Info

此问题已关闭。 请重新打开它进行编辑或回答。

how to import a file from xls

1 次查看(过去 30 天)
Niki
Niki 2015-8-30
关闭: MATLAB Answer Bot 2021-8-20
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

回答(1 个)

Star Strider
Star Strider 2015-8-30
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.

此问题已关闭。

标签

Community Treasure Hunt

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

Start Hunting!

Translated by