Generation of similar vectors

3 views (last 30 days)
moncef soualhi
moncef soualhi on 23 Sep 2019
Commented: moncef soualhi on 26 Sep 2019
Hi every one,
I have a vector of points which represents a regressive form (as shown in the attached file). This vector containes 1112 samples and i want to generate similar vectors with the same trend (regressive). However, i want that these vectors have different length (=/= 1112) by knowing tha the threshold is equal to 1.
To summirize, i want to know how to generate vectors with the same trend of the original one bu with different length, exp: 2000, 500, 400, etc. and the final amplitude of each vector is equal to the threshold (1).
Thank you very much for our attention and your help.
Best regards

Accepted Answer

darova
darova on 23 Sep 2019
What about interp1()?
load data.mat
y = data;
x = 1:length(y);
x1 = linspace(x(1),x(end),1000);
y1 = interp1(x,y,x1);
plot(x,y,x1,y1,'r')
Look also for spline()
  5 Comments
darova
darova on 25 Sep 2019
For moving ix Y direction you have to use function that has zero values at start/end
For moving in X direction only start has to be zero
clc,clear
load data.mat
y = data';
n = length(y);
x = (1:n);
% modificate data using x^2
xr = linspace(-1,1,length(x));
yr = -(xr.^2-1); % zero at the ends
subplot(411)
plot(x,y, x,y-0.1*yr,'r') % move data down
subplot(412)
plot(x,y, x,y+0.1*yr,'r') % move data up
% modificate data using sin(x)
xr1 = linspace(0,pi,length(x));
yr1 = sin(xr1); % zero at the ends
subplot(413)
plot(x,y, x,y-0.2*yr1,'r')
subplot(414)
plot(x,y, x-100*yr1,y+0.2*yr1,'r')
moncef soualhi
moncef soualhi on 26 Sep 2019
Thank you for your help

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!