资源简介
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 GPS卫星星座仿真
- matlabR2011b 2017年以后破解可用亲测
- 线性时变系统PID控制的matlab仿真程序
- matlab编写的激波计算程序
- Matlab粗糙表面数字仿真
- EKF MATLAB函数
- 手写数字识别matlab实现(原代码)
- MATLAB 字符识别
- matlab的粗糙集代码
- 分形图像编码的matlab实现
- 系统辨识与自适应控制matlab仿真庞中
- 主成分分析PCA matlab
- 图像增强Matlab代码总结6种
- 永磁同步电机matlab仿真模型 PMSM_PI
- MATLAB实现灰色预测程序
- hdb3编码解码的matlab编码
- matlab雨流计数法
- 弗洛伊德 算法matlab
- 压缩感知算法的matlab仿真源码
- Matlab实现nearest+bilinear+bicubic插值resi
- 飞机纵向增稳系统设计matlab
- matlab renix 文件读取代码
- 粒子滤波算法介绍及MATLAB工具箱
- 广义预测控制Matlab程序
- 通过knn算法,实现WiFi室内定位在mat
- 云计算,matlab
- 用户均衡流量分配模型UE的matlab求解程
- 回溯搜索算法 matlab BSA.m
- 概率神经网络分类matlab代码
评论
共有 条评论