Clear Filters
Clear Filters

How to adjust data?

4 views (last 30 days)
Kacper Suchecki
Kacper Suchecki on 17 Jan 2021
Commented: Star Strider on 20 Jan 2021
Hi,
I need help. I had get data of signal but it doesnt seems good. I want to have straight signal with limit 200 on below and up to 1100 on the top, by only adjusting him not cuting.
I tried something like this .
for x 1:5000005
if x<40000
wspolrzedna(x)=wspolrzedna(x)-100;
end
if x<100000 & x>40000
wspolrzedna(x)=wspolrzedna(x)+200;
end
if x<300000 & x>100000
wspolrzedna(x)=wspolrzedna(x)+300;
end
if x<500000 & x>300000
wspolrzedna(x)=wspolrzedna(x)+500;
end
if x<750000 & x>500000
wspolrzedna(x)=wspolrzedna(x)+750;
end
if x<1000000 & x>750000
wspolrzedna(x)=wspolrzedna(x)+1000;
end
end
I get only something like this. I please for help. Thanks. (The plots plots are built in time scale , the code was write using samples. I have 5000005 samples which i want adjust )

Accepted Answer

Star Strider
Star Strider on 17 Jan 2021
It would be easiest to use the detrend function:
t = linspace(0, 100, 1E+4); % Create Data
s = sin(2*pi*t) + 0.001*(t-50).^2; % Create Data
figure
plot(t,s)
grid
s_det = detrend(s, 3); % Detrend Using 3° Polynomial
figure
plot(t, s_det)
grid
.
  2 Comments
Kacper Suchecki
Kacper Suchecki on 20 Jan 2021
Thanks. It's work pretty well.
Star Strider
Star Strider on 20 Jan 2021
As always, my pleasure!

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!