stretching a non-monotonically increasing vector
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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
1 comentario
Respuestas (3)
Guillaume
el 28 de Feb. de 2015
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, :)
0 comentarios
Michiel
el 28 de Feb. de 2015
1 comentario
Guillaume
el 2 de Mzo. de 2015
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)
el 1 de Mzo. de 2015
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')
0 comentarios
Ver también
Categorías
Más información sobre Characters and Strings en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!