MATLAB Answers

Please help. I need to read this file and isolate column 2.

조회 수: 2(최근 30일)
Charles Naegele
Charles Naegele 17 May 2018
댓글: John BG 18 May 2018
It appears the data is not separated into columns. Any way to do this?
A = importdata('Psmall.txt');
A1 = A(:,2);

  댓글 수: 5

표시 이전 댓글 수: 2
Charles Naegele
Charles Naegele 17 May 2018
It's returning a column vector with all values (i.e. 22... 3.3...) as if both columns of numbers are within one column. Thanks for trying it for me.
the cyclist
the cyclist 17 May 2018
To be clear, when I run your code, I get an Nx2 matrix (of data type "double"). As Star Strider said, it is then easy to separate them into the column vector.
Is that what you get?
Charles Naegele
Charles Naegele 18 May 2018
You were both correct, I had it right in the original code. Sorry for the confusion. Thanks for your responses!

로그인 to comment.

채택된 답변

John BG
John BG 17 May 2018
Hi Charles Naegele
You are having the same result as if you were using textscan instead of importdata
B2 has as single column with all data, as you mention it happens in your data acquisition.
Note that your data file has a TAB as separator, not the default ' ' (space) or comma. Despite MATLAB help for import data reads
The default character is interpreted from the file.
It may be the case an earlier version of MATLAB doesn't really consider TAB as a column separator.
If you upgrade your MATLAB version you will solve this and possibly other compatibility issues to come.
If you find this answer useful would you please be so kind to consider marking my answer as Accepted Answer?
To any other reader, if you find this answer useful please consider clicking on the thumbs-up vote link
thanks in advance for time and attention
John BG

  댓글 수: 2

Charles Naegele
Charles Naegele 18 May 2018
Turns out I had it correct in the original code, but I thought this answer might be useful to someone else in the future. Thanks!

로그인 to comment.

추가 답변(0개)

이 질문에 답변하려면 로그인을(를) 수행하십시오.


Translated by