How can I modify vector length?

I have several vectors to compare, however they all slightly differentiate by length. I know that first numbers of vectors are zeros. Can I cut those number to get vectors of same length? I don't want to pad vectors with zeros, because in this case I wouldn't be able to calculate an error between vectors?
Or may be there is a way to calculate error ratio between two vectors, even if they have different length?

4 comentarios

Jan
Jan el 12 de Mayo de 2018
How do you defined an "error" ratio of vectors, when they have a different length? Why does zero padding not help, but zero cropping does? And if zero cropping does, why don't you do it?
Note that it is hard to suggest a solution, which matches your needs exactly, because the readers cannot guess, what "I have several vectors" mean. Do you mean 20 vectors store in a cell array, or 20'000 vectors in different variables?
DenisK
DenisK el 12 de Mayo de 2018
I have 4 vectors stored in different variables. Error evaluation I want to perform by mean absolute percentage error (MAPE) method, and it's code looks like this:
Error1 = abs(mean(abs(clin - ccirc')./clin)*100)
However, as a result I get NaN. Even after cropping zeros.
Jan
Jan el 12 de Mayo de 2018
Please post the data. If the inputs contain NaNs, the result must be NaN also.
DenisK
DenisK el 12 de Mayo de 2018
The data is an mp3 file, so I cannot attache it here. Vectors that I built are result of few convolution methods, that I need to compare (linear, circular, overlap save and overlap add). I took linear convolution result as a reference vector.

Iniciar sesión para comentar.

 Respuesta aceptada

Jan
Jan el 12 de Mayo de 2018
If cropping the zeros solves the problem, crop the zeros:
v = [0,0,1,2,3,4]
v = v(find(v, 1):length(v))

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.

Preguntada:

el 12 de Mayo de 2018

Comentada:

el 12 de Mayo de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by