类型为'iddata'的输入参数的未定义函数'minus' [英] Undefined function 'minus' for input argument of type 'iddata'
问题描述
这是我之前遇到的问题的后续行动.
我想给信号提供一个偏移量,然后在其中添加一些延迟并为此计算RMSE,但是当出现差异时,我会遇到以下问题:
I want to give an offset to a signal then add some delay in it and calculate RMSE for that but when taking difference I am having the following issue:
我想问以下事情:
- 我该如何解决以上问题?
- 请任何人用简单的词来解释
iddata
的作用-因为我研究了包括MATLAB在内的不同门户,但仍然无法获得一个好的概念. - 如何将
iddata
类型的数据存储在单元格中以便在代码的最后部分进行减法运算?
- How can I solve the above problem?
- Will anybody please explain in simple words what
iddata
does - because I have studied different portals including MATLAB but remained unable to get a good concept. - How can I store data of type
iddata
in cell for subtraction in the last part of my code?
有问题的代码:
drv(1)=load('123.mat');
t = drv(1).x;
ref = drv(1).y;
angle = drv(1).z;
Fs = 1000;
t1 =t';
ref1= ref';
d_data = iddata(ref1, t1, 1/Fs);
%% Add offset:
x = 1;
afterOffset1= {};
for i = 100:10:130
T = getTrend(d_data);
% <detrend data if needed>
T.InputOffset = i;
T.OutputOffset = i;
afterOffset = retrend(d_data,T);
afterOffset1{x,1}= afterOffset;
x= x+1 ;
end
%% Add delay:
y=20;
afterDelay1= {};
for i = 1:1:4
% delaySamples = i; % Must be a non-negative value
% afterDelay = iddata([NaN(delaySamples,1); d_data.OutputData],...
% [d_data.InputData; NaN(delaySamples,1)], 1/Fs);
afterOffset1{i}.Tstart = y;
afterDelay1{i,1}= afterOffset1{i};
y= y+10;
end
%% Plot:
n = size(afterDelay1,1);
figure();
for i=1:1:n
subplot(2,2,i);
plot(d_data);
hold all
plot(afterDelay1{i});
end
sig_diff = angle(1)-afterDelay1;
square_error(i,:) = (sig_diff(i)).^2;
mse(i,:)= mean(square_error(i));
rmse(i,:) = sqrt(mse(i));
sig_diff = d_data_1 - afterDelay; % <<<<<<<<<<<<<<<<<<<<<< Problem is here
% square_error = (sig_diff).^2;
% mse= mean(square_error);
% rmse = sqrt(mse);
end
推荐答案
您最可能希望从iddata
对象获得OutputData
属性,该属性是您问题的输出或y
信号:
You most likely want the OutputData
attribute from the iddata
object which is the output or y
signal of your problem:
sig_diff = angle(1)-afterDelay1.OutputData;
还请注意,这将为您提供一个列向量,但是稍后您的代码假定它是一个行向量.在执行以上计算之后,您可能需要转置此数据,然后继续:
Also note that this will give you a column vector, but your code later on assumes it's a row vector. You may want to transpose this data after you perform the above calculation before proceeding:
sig_diff = angle(1)-afterDelay1.OutputData;
sig_diff = sig_diff.';
通常,iddata
是创建代表输入和输出时域或频域数据的对象的函数.请注意,创建iddata
对象时,输入矩阵可能具有多个来源,因此每个列都指定一个来源.对于每个列指示输出的输出,可以说相同.因此,在使用此功能之前,请先对数据进行转置,以确保每个信号都位于单独的列中,或者仅使用单个列来代表一个输入/输出,这一点非常重要.
In general, iddata
is a function that creates an object that represents input and output time or frequency domain data. Take note that when you create an iddata
object, the input matrix can potentially have multiple sources and so each column dictates a source. The same can be said for the output where each column dictates an output. Therefore, it is very important that you transpose your data prior to using this function to ensure that each signal is in a separate column, or just use a single column to represent one input / output.
对象内部具有多种属性,包括采样时间或采样频率,函数所采用的有效域和范围以及最终访问输入和输出数据的范围. OutputData
是这些字段之一.我建议您阅读有关使用iddata
可以访问的所有属性的文档. OutputData
在此处明确定义: https://www.mathworks.com/help/ident/ref/iddata.html
Inside the object has a variety of attributes, including the sampling time or sampling frequency, the valid domain and range that the function takes on and finally accessing the input and output data. OutputData
is one of these fields. I'd recommend looking at the documentation that talks about all of the attributes that you can access with iddata
. OutputData
is clearly defined here: https://www.mathworks.com/help/ident/ref/iddata.html
这篇关于类型为'iddata'的输入参数的未定义函数'minus'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!