필터 지우기
필터 지우기

stretching a non-monotonically increasing vector

조회 수: 4 (최근 30일)
Michiel
Michiel 2015년 2월 28일
댓글: Guillaume 2015년 3월 2일
Hi,
I have the following vector structure (optimal input returned from tomlab)
u = [0 1 1 0 1 0 0 1 0] and I want to stretch it so I obtain
u_new = [0 0 0.5 1 1 1 1 0.5 0 0 0.5 1 1 0.5 0 0 0 0 0.5 1 1 0.5 0 0]
where all values must remain between the upper and lower values from the original array.
interp1 is not suited, imresize does not seem to do the trick either. Any suggestions are appreciated

답변 (3개)

Guillaume
Guillaume 2015년 2월 28일
Can you explain the rule you used to create your u_new? (and why its number of elements is not a multiple of the original).
I can get fairly close with:
u_new = floor(2 * imresize(u, 3, 'bilinear')) / 2;
u_new = u_new(1, :)

Michiel
Michiel 2015년 2월 28일
okay, I don't have the rule, if I did I would not ask the question :). But it is a bit more complicated
the true optimal input vector (u) I have varies. It contains 60 elements always, which are any value between 0 and 1 and describe a trajectory in between a sine wave and step functions (thus, domains going up, domains going down, and at certain intervals constantly 0 or 1), at non-regularly spaced time intervals, looking like: t=[1:variable:19.9]' in my case.
now I want to "stretch" this, by which I mean interpolate the data, such that I obtain the values at 200 regularly spaced time intervals (t=[1:0.1:19.9]')
  댓글 수: 1
Guillaume
Guillaume 2015년 3월 2일
Please use 'Comment on this Answer' rather than starting a new answer.
You must have followed some rule to create your example of u_new. Furthermore, you must have some rule for saying that the result produced by "interp1 is not suited" and that "imresize does not seem to do the trick either".
We can attempt to provide solutions ad nauseam, but without any criteria for what the result should be, we'll be here forever.

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


Jos (10584)
Jos (10584) 2015년 3월 1일
You do want to take a look at interp1
t = [1 3 4 6 9] ; % irregular time intervals
y = [0 1 1 0 1] ;
t1 = 1:9 ; % regular time intervals
y1 = interp1(t,y,t1,'linear')

카테고리

Help CenterFile Exchange에서 Filter Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by