Entering huge arrays of numbers...

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 Comments

per isakson
per isakson on 13 Feb 2015
Edited: per isakson on 13 Feb 2015
"given a set of data that i need to enter into matlab" &nbsp Is that in the form of a text file? In that case what is the format? How do you want data organised in Matlab? Did you try the tool, Import Data under the HOME tab?
I have time and corresponding temp. like below:
Time Temp
.01 22.59708
.02 22.61797
.03 22.59888
etc...
I need to plot the data in matlab but there are 10 pages worth. i want to plot temp vs time. it is currently on online file.
I assume
  • this is a snap-shot of the first few lines of a text file!
  • you did not try the tool, Import Data under the HOME tab
Am I correct?
correct
So use textread, or any of a huge variety of tools. Whats the problem?

Sign in to comment.

Answers (3)

John D'Errico
John D'Errico on 13 Feb 2015
Edited: John D'Errico on 13 Feb 2015
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 on 13 Feb 2015
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 Comments

the times are in .01 increments. but the corresponding temp values do not increase uniformly. i have all the given times and corresponding temps, but it is too much data to enter manually. here is a small sample of what was given:
Time Temperature
0.01 22.72926
0.02 22.50903
0.03 22.75125
0.04 22.56175
0.05 22.69901
0.06 22.5808
Noise is normal in empirical measurements. That’s the reason statisticians get the big bucks.
How do you want to handle the variability? I would either just leave it alone, or if you have a mathematical model of how it should work, fit a linear or nonlinear regression curve to it. The model depends on the system you are measuring, the time-temperature curve you hypothesize, the thermocouple interface, and other technical issues.
It would be best if you also had a model of your thermocouple and could model the voltage and linearisation of it with respect to temperature, as well. That might help you get a comprehensive temperature-voltage model, but then thermocouple interfacing circuitry could have advanced to the point that such is not an issue since I last dealt with them.
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 on 13 Feb 2015
Edited: Star Strider on 13 Feb 2015
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.

Sign in to comment.

per isakson
per isakson on 13 Feb 2015
Edited: per isakson on 13 Feb 2015
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

Categories

Tags

Asked:

on 12 Feb 2015

Commented:

on 14 Feb 2015

Community Treasure Hunt

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

Start Hunting!