Entering huge arrays of numbers...

조회 수: 6 (최근 30일)
Joseph
Joseph 2015년 2월 12일
댓글: John D'Errico 2015년 2월 14일
I have a thermocouple problem I am working on. I am given a set of data that i need to enter into matlab before I can get started. The data I have is time and corresponding temperature. I can get the time into matlab because it is at set intervals, but the temperatures are sporadic. how do you input a very large set of data(10 pages) that has a start and ending value, but no specific increment? Any help would be greatly appreciated.
  댓글 수: 5
Joseph
Joseph 2015년 2월 13일
correct
John D'Errico
John D'Errico 2015년 2월 14일
So use textread, or any of a huge variety of tools. Whats the problem?

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

답변 (3개)

John D'Errico
John D'Errico 2015년 2월 13일
편집: John D'Errico 2015년 2월 13일
Read it in from a file, as a list of (time, temperature) pairs. So it can be either a 2-d array with say two columns, or a pair of vectors. If the times span too long of a time, you will probably need datenum to convert them into a numeric time format.
If you have the data, surely you can get it into an simple text file, or even an Excel spreadsheet? Start typing.

Star Strider
Star Strider 2015년 2월 13일
I’d appreciate a bit more information. What do you mean by ‘the temperatures are sporadic’? Do you have constant sampling times but the temperatures are missing from some of them, or do the temperatures have a large amount of variability?
There may be several ways to deal with your data once we know a bit more about it. No guarantees though with what you’ve already told us.
  댓글 수: 4
Joseph
Joseph 2015년 2월 13일
Thanks, but I really just need to get the data into matlab so i can plot it. Is there a way to get data from a file into matlab? it is an internet file
Star Strider
Star Strider 2015년 2월 13일
편집: Star Strider 2015년 2월 13일
For an Internet file, there are several ways to read it. Unfortunately, these have also changed between MATLAB versions, so you may need to search the documentation for your version. The online documentation (for R2014b) is the collection of routines linked to in Web Access.
After you download it, reading it into your MATLAB workspace depends on the file format. That is another huge subject, so I refer you to the documentation for Data Import and Export.
It’s not as daunting as it seems. It becomes a lot simpler when you know more details about the file.

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


per isakson
per isakson 2015년 2월 13일
편집: per isakson 2015년 2월 13일
This is the way I would do it
fid = fopen( 'cssm.txt' );
cac = textscan( fid, '%f%f', 'Headerlines', 1, 'CollectOutput', true );
fclose( fid )
num = cac{1};
plot( num(:,1), num(:,2) )
where cssm.txt is in the current directory (if not use a full filespec ) and contains
Time Temp
.01 22.59708
.02 22.61797
.03 22.59888

카테고리

Help CenterFile Exchange에서 Standard File Formats에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by