CSV file imported with readmatrix is misreading the data in the CSV file

I'm trying to read a roughly 400 row csvfile consisting of one column of 3 digit numbers and 35 colums of 8 digit integres. The resulting array consists of 5 digit numbers with a decimal point after the first number. This isn't too helpful. The numbers represent measured frequencies in the 15MHz range so I'm losing data when importing

답변 (4개)

per isakson
per isakson 2019년 11월 18일
편집: per isakson 2019년 11월 18일
"The resulting array consists of 5 digit numbers with a decimal point after the first number." I assume that you describe how the numbers are displayed in the Command Window.
Try
format long
Example:
>> format long
>> pi
ans =
3.141592653589793
>> format short
>> pi
ans =
3.1416
>>
"I'm losing data when importing" No, it's only a question of how the values are presented.
James Andrada
James Andrada 2019년 11월 18일

0 개 추천

Thanks
It turned out that "longEng" displays them correctly - values were OK but displaying incorrectly.
By the way, is there any way to associate the format type with a variable, not globally for the workspace. Using "longEng" for 3 digit integres is very clumsy.
James Andrada
James Andrada 2019년 11월 18일

0 개 추천

Thanks. That's too bad. I guess I just need to issue a format command before printing.

댓글 수: 1

"printing" See the documentation on fprintf.
Example
>> fprintf( 1, '%.2f\n', pi )
3.14
>> fprintf( 1, '%.4f\n', pi )
3.1416

댓글을 달려면 로그인하십시오.

James Andrada
James Andrada 2019년 11월 18일

0 개 추천

Thanks much. That's very helpful. I was thinking there might be a way to do it but hadn't had time to look into it yet today.

카테고리

도움말 센터File Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

제품

질문:

2019년 11월 18일

답변:

2019년 11월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by