How to convert a .txt to .cdf ? Needed for Matlab that won't read txt as cdf
6 次查看(过去 30 天)
显示 更早的评论
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!
0 个评论
回答(1 个)
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!