How to convert a .txt to .cdf ? Needed for Matlab that won't read txt as cdf

6 ビュー (過去 30 日間)
Paul
Paul 2014 年 3 月 18 日
回答済み: dpb 2014 年 3 月 18 日
I have a txt file that contains data in Common Data Format( CDF ). Matlab has functions to read this but it does not work. I assume because the extension is .txt and not .cdf. When I try to read it I get:
??? Error using ==> cdfinfoc Error issued from CDF library: "NOT_A_CDF_OR_NOT_SUPPORTED: Named CDF is corrupted or not supported by the current library version."
Error in ==> cdfinfo at 170 tmp = cdfinfoc(filename);
Error in ==> cdfread at 184 info = cdfinfo(filename);
Is there a way to trick Matlab and read it or do I need to transform somehow the txt into a .cdf? If so, how do I do that?
Thank you!

回答 (1 件)

dpb
dpb 2014 年 3 月 18 日
I seriously doubt the extension has anything to do with it; the message indicates it's either not actually a .cdf file at all (one might expect it's just an ASCII file given the name?) or a later revision than the TMW library functions in your Matlab version.
But, you can prove this easily, just copy the file over to another with the wanted extension and try again -- but I'm betting you'll get the same result.
copyfile('yourcurrentfile',['yourcurrentfilebasename' '.cdf'])
You could, of course, just rename it but the above gives you a copy w/ the new name.
Iff'en as expected that has the same result, you might just try
edit 'yourcurrentfile'
or
type 'yourcurrentfile'
and see if it isn't just a plain ol' ordinary text file.

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by