stretching a non-monotonically increasing vector
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaire
Réponses (3)
Guillaume
le 28 Fév 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 commentaires
Michiel
le 28 Fév 2015
1 commentaire
Guillaume
le 2 Mar 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)
le 1 Mar 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 commentaires
Voir également
Catégories
En savoir plus sur Characters and Strings dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!