0
votes

I want to resample an array of elements using the command idresamp(). The input arguments for idresamp function is an array x. So I should get the output as an array. However, I am getting a structure iddata. I don't know how to access the elements /result of the resampling. Can somebody please show how to access the resampled values? Thank you.

  x=rand(4000,1); %create some arbitrary data
  x_resamp =idresamp(x,2); %resampling factor is 2

Here x_resamp is of iddata type. So, I am unable to access the result. On clicking the variable x_resamp this is what I got

img

How does one access the resampled values (output). Where is the array? The next step is to calculate the power after resampling and hence I need to use the resampled values.

I am using Matlab R2018a.

1
Did you look through the documentation to iddata? Alternatively, use resample, which returns a normal array. - Cris Luengo
The docs say to use data.InputData or data.OutputData, depending on which data you want to get out. It seems you have only output data in your object? - Cris Luengo
@CrisLuengo I looked into resample but could not understand what should be the value of the parameter if I want to resample by 2 as there are 2 arguments in this function. For the second comment, I only have output data in my object. So, what should I do? - Srishti M
In the example of resample th line ur = resample(u,3,2); means that P=3 and Q=2 which should resample the data u by Q/P = 2/3 according to the documention. But the explanation under the example says: "Increase the sampling rate of data by a factor of 1.5 and compare the resampled and the original data signals." To get the sampling factor of 1.5 we should be doing P/Q and not Q/P . Therefore, the explanation on how to mention the sampling factor is not clear. - Srishti M

1 Answers

2
votes

If you just want to resample by a factor 2, and have access to the Signal Processing Toolbox, use resample:

y = resample(x,2,1);

If you are insistent on using idresamp, you need to know that it returns an object of type iddata, which comes with a long documentation on usage. I think this complicates things more than you are looking for. It seems you should be able to do:

x_resamp = idresamp(x,2);
y = x_resamp.OutputData;

(but I can't test this because I don't have access to this toolbox.)