How to resize this vector?

I have a vector A of 64 data points which corresponds to 15.66 cm projection. I need to get a vector B of projection data points of size 64 which corresponds to 0.48 cm in the middle of A. How to get it?

 Respuesta aceptada

Walter Roberson
Walter Roberson el 25 de En. de 2016

1 voto

extract_starting_from = 12.345; %for example
extract_length = 0.48;
orig_X = linspace(0, 15.66, length(A));
new_X = linspace(extract_starting_from, extract_starting_from+extract_length, 64);
extracted_A = interp1(orig_X, A, new_X);

2 comentarios

dsp
dsp el 7 de Jul. de 2016
Editada: dsp el 7 de Jul. de 2016
on a related note,
I have a vector A of 64 data points which corresponds to 2 cm projection. I need to get a vector B of projection data points of size 64 which corresponds to 4 cm in the middle of A. How to get it?
Is extrapolation any good or adding zero will be good?
extract_starting_from = -1; %for example
extract_length = 4;
orig_X = linspace(0, 2, 64);
new_X = linspace(extract_starting_from, extract_starting_from+extract_length, 64);
extracted_A = interp1(orig_X, A, new_X,'pchip','extrap');
Walter Roberson
Walter Roberson el 8 de Jul. de 2016
? How can you get 4 cm in the middle of something that is only 2 cm long?
'pchip' might be valid for your purposes; 'linear' might be valid. Also specifying 0 instead of 'extrap' might be valid. It depends on what you are modeling.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Interpolation en Centro de ayuda y File Exchange.

Preguntada:

dsp
el 25 de En. de 2016

Comentada:

el 8 de Jul. de 2016

Community Treasure Hunt

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

Start Hunting!

Translated by