Load function not properly loading a numeric ASCII file
이전 댓글 표시
I am trying to load and ASCII file that is 24X48. The load function will not load the load the actual values in the work space. It will load zeros. The "readtable" will work without a problem but it puts in format has to be converted into an array and can only be done after individual values are pulled out, put into a 1X1 table then converted into an array. I am using R2018a at this time. I never had this problem with my old version R2008b.
Is there a way to use the load function on a ASCII file that is in the form of a table that will not cause this issue?
Ideally, I need a function that can load in an ASCII file into the workspace as an array quickly without jumping through hoops and allow the data to be either a character or an integer or number?
댓글 수: 9
Matthew Benedict
2018년 9월 28일
You may want to take a look at this function that can handle mixed types in a delimited file: https://www.mathworks.com/matlabcentral/fileexchange/10946-readtext
Walter Roberson
2018년 9월 28일
편집: Walter Roberson
2018년 9월 28일
Please attach an example of the file.
If you have a table, T, that consists entirely of numeric values, then
T{:,:}
would be a numeric array of the values.
Eric Metzger
2018년 9월 28일
Walter Roberson
2018년 9월 28일
Looks to me as if it might be tab delimited. I do not see any reason for load() to load it as zeros, though. It would be better if you could attach an extract rather than just an image of a portion of it.
Eric Metzger
2018년 9월 29일
Walter Roberson
2018년 9월 29일
Try giving the command
format long g
and then displaying the data again.
Eric Metzger
2018년 9월 29일
Star Strider
2018년 9월 29일
The load function imported it correctly when I tried it. (See my Answer.)
Walter Roberson
2018년 9월 29일
I just tried it on R2018a on Windows 10. load() worked fine for me. I did have to use
format long g
to be able to see the full range of values.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Cell Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
