필터 지우기
필터 지우기

How to make a list of iddata objects

조회 수: 6 (최근 30일)
Bill Tubbs
Bill Tubbs 2020년 3월 22일
답변: Bill Tubbs 2020년 3월 22일
I'm loading data from a bunch of csv files and making each one into a iddata object.
How do I create a collection from the resulting iddata objects?
I thought cell arrays were the way to go (as described here) but I'm getting a criptic error
Code snippet:
% Store data sets in this cell array
dataSets = {};
% Loop through files
for k = 1 : length(theFiles)
file = theFiles{1, k};
fprintf(1, "Reading file '%s'\n", file.name);
filePath = fullfile(file.folder, file.name);
% Read data from file
dataTable = readtable(filePath);
% Create dataset object for system identification
inputData = table2array(dataTable(:,2:3));
outputData = table2array(dataTable(:,4:5));
dataSet = iddata(outputData,inputData);
dataSets = [dataSets, dataSet];
end
The line
dataSets = [dataSets, dataSet];
generates this error message:
Undefined function 'realdata' for input arguments of type 'cell'.
Error in iddata/horzcat (line 19)
reald = realdata(dat);
  댓글 수: 1
Bill Tubbs
Bill Tubbs 2020년 3월 22일
I've tried googling this error message and there are no search results on the internet.

댓글을 달려면 로그인하십시오.

채택된 답변

Bill Tubbs
Bill Tubbs 2020년 3월 22일
Here is a solution. Use the index to assign to the cell array:
% Loop through files
for k = 1 : length(theFiles)
file = theFiles{1, k};
fprintf(1, "Reading file '%s'\n", file.name);
filePath = fullfile(file.folder, file.name);
% Read data from file
dataTable = readtable(filePath);
% Create dataset object for system identification
inputData = table2array(dataTable(:,2:3));
outputData = table2array(dataTable(:,4:5));
dataSet = iddata(outputData,inputData);
dataSets{k} = dataSet;
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Preparation Basics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by