MATLAB Answers

How to read file using textscan

1 view (last 30 days)
Aoyi
Aoyi on 5 May 2018
Answered: Alfonso on 5 May 2018
I have a file with 4 row:
SiteNo time mintemperature maxtemperature
The time have already change into matlab format time. How can I read the file using textscan?

  0 Comments

Sign in to comment.

Accepted Answer

Alfonso
Alfonso on 5 May 2018
You could try:
filename = 'myFile.txt'; % example
fileID = fopen(filename);
C = textscan(fileID,'%d %s %.2f %.2f'); % SiteNo(integer), time(string), maxtemp and mintemp(float with 2 decimal),
fclose(fileID);

  0 Comments

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!