Having trouble importing data from LABVIEW to MATLAB

I'm attempting to import data from labview to MATLAB for analysis. I can't figure out which import function to use and I could use some help. I've attached the type of data that I will regularly come into contact with. The raw data leaves the software with absolutely no extension. On my computer, which has a windows 7 operating system, they denote the type of file extension as "File" and I think this may be the source of why I'm having so much trouble. The attachment to this forum post is a ".txt" file (entirely because this forum will not allow me to upload the file as it is originally), but this is not how they come to me in raw format. I had to modify the file by simply attaching ".txt" when renaming the file. All in all, if it is possible to import the data in it's raw file form (i.e. "File" form) and without attaching ".txt" to every file I am interested in, that would be the best possible scenario.

Réponses (1)

I would use textscan:
fidi = fopen('Nicholas Frank 402-149 AD102-005rerun.txt','r');
Data = textscan(fidi, '%s%s%f%f', 'HeaderLines',6, 'Delimiter','\t', 'CollectOutput',1);
DateTimeC = Data{1};
DateTimeS = [char(DateTimeC(:,1)), repmat(' ', size(DateTimeC,1), 1) char(DateTimeC(:,2))]; % Date & Time As Strings
DateTimeN = datenum(DateTimeS, 'mm/dd/yyyy HH:MM:SS PM'); % Date & Time As Date Numbers
Sig_Temp = Data{2}; % Signal & Temperature Matrix

6 commentaires

Nicholas  Frank
Nicholas Frank le 20 Jan 2016
Modifié(e) : Nicholas Frank le 20 Jan 2016
I'm using Octave by the way, but it shouldn't make any difference. I get this error message:
warning: textscan: 'headerlines' ignored when reading from strings
warning: called from
textscan at line 181 column 7
main at line 29 column 8
warning: strread: unknown property 'HeaderLines'
It would probably make a difference, because the Octave version of textscan could be different, and when I did a DuckDuckGo search, there were posts in 2014 that indicated problems with the 'headerlines' implementation in Octave. I have no idea if they have been fixed in subsequent releases.
My code ran without error in MATLAB R2015b.
I have no experience with Octave, so I cannot help you with it specifically. The only things I can suggest is that you call fgets six times in a loop, and then use textscan without the 'headerlines' option, or create a duplicate version of your file with a slightly different name, and manually edit out the first six lines. Then read it with textscan (without 'headerlines') and save the data as a .mat file. The rest of my code could work in Octave, but I cannot guarantee it.
I appreciate your help. I'll see what I can do with what you've given me and I'll get back to you once I've determined a solution!
My pleasure.
I added the ‘octave’ tag to your Question as well.
We are not qualified to answer questions about Octave here. Octave questions should be asked in the Octave forums.
It’s safe to say that if I’d known it was an Octave question, so that my Answer (and effort behind it) turned out to be irrelevant, I’d not have bothered. I quite definitely have better uses for my time.

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by