资源简介
matlab读取comtrade文件支持文本与二进制
代码片段和文件信息
function read_comtrade
%读取文本与二进制
%% Comtrade Reader function
%
% This file is designed to decode the data stored in COMTRADE format
% as defined in IEEE C37.111-1999. This involves the opening of two files
% one containing the configuration (.cfg) information and the other
% the data (.dat).
%
% COMTRADE provides a common format for the data files and exchange medium
% needed for the interchange of various types of fault test or simulation
% data.
%% open the comtrade files & extract the data
% read_comtrade(filename)
% Imports data from the specified file
% filename: files to read .cfg and .dat
% Auto-generated by MATLAB on 12-Jul-2007 13:45:45
% Use the uigetfile function to load the .cfg file which is then used to
% load the associated .dat file
% First get the .cfg file information
[CfgFileNamePath] = uigetfile(‘*.cfg‘);%载入.CFG文件
PathAndCfgName =[Path CfgFileName]; %PathAndCfgName =路径\文件名.cfg eg. PathAndCfgName =E:\研究生\项目\READE_comtrade\262-RCS902A.cfg
% Derive the .dat file string
%DatFileName = strcat(sscanf(CfgFileName‘%1s‘length(CfgFileName)-4) ‘.dat‘);
DatFileName = [CfgFileName(:1:length(CfgFileName)-4) ‘.dat‘];%dat文件名
PathAndDatName =[Path DatFileName];%dat路径加文件名
% Store the file name (minus extension) and path in the workspace
assignin(‘base‘‘Path‘ Path);
assignin(‘base‘‘FileName‘ sscanf(CfgFileName‘%1s‘length(CfgFileName)-4));
% Now open the .cfg and .dat files
cfg_id = fopen(PathAndCfgName);
% Scan the text into local cells cfg and dat.
cfg = textscan(cfg_id ‘%s‘ ‘delimiter‘ ‘\n‘);
% close all open files as we‘re done with them now.
fclose(cfg_id);
%% start to decode the data
cfg_len = length(cfg{11});
cfg_string = cell(size(cfg));
for i = 1:cfg_len
temp_string = char(cfg{11}{i});
cfg_string{i} = strread(temp_string ‘%s‘ ‘delimiter‘ ‘‘)‘;
end
% Comtrade File Identifier
title = char(cfg_string{11}(1));
% Comtrade Version
if length(cfg_string{11}) < 3 %#ok
Version = ‘1999‘;
else
Version = char(cfg_string{11}(3));
end
% Channel information: total analogues and digitals
No_Ch = strread(char(cfg_string{12}(1)));%总通道数量
Ana_Ch = strread(char(cfg_string{12}(2)));%模拟量量通道数
Dig_Ch = strread(char(cfg_string{12}(3)));%数字量通道数
% Nominal frequency
frequency = strread(char(cfg_string{13+No_Ch}(1)));
rates = strread(char(cfg_string{14+No_Ch}(1)));
No_Ch =No_Ch+rates-1;
% Sampli
- 上一篇:MATLAB GPS卫星星座仿真
- 下一篇:数字图像处理-圆拟合matlab代码
相关资源
- MATLAB 经典程序源代码大全
- MATLAB小波软阈值去噪代码33473
- 天线阵的波束形成在MATLAB仿真程序及
- 非线性SVM算法-matlab实现
- 《MATLAB 智能算法超级学习手册》-程序
- 组合导航matlab程序
- 读取txt文件内容matlab代码实现
- Matlab实现基于相关的模板匹配程序
- matlab优化工具箱讲解
- 基于MATLAB的快速傅里叶变换
- 光纤传输中的分布傅立叶算法matlab实
- 基于matlab的图像处理源程序
- matlab 椭圆拟合程序
- 算术编码解码matlab源代码
- optical_flow 光流法 matlab 实现程序
- 引导图像滤波器 Matlab实现
- 分形几何中一些经典图形的Matlab画法
- OFDM系统MATLAB仿真代码
- SVM工具箱(matlab中运行)
- 图像小波变换MatLab源代码
- LU分解的MATLAB实现
- 冈萨雷斯数字图像处理matlab版(第三
- 替代数据法的matlab程序
- 用matlab实现的多站定位系统性能仿真
- 通过不同方法进行粗糙集属性约简m
- k近邻算法matlab实现
- matlab识别系统
- 神经网络分类matlab程序
- matlab正弦信号发生器的设计
- matlab程序用Hopfield网络解决TSP
评论
共有 条评论