Borrar filtros
Borrar filtros

Error using interp1>re​shapeAndSo​rtXandV X and V must be of the same length

6 visualizaciones (últimos 30 días)
So i am working on development of GUI (fig attached) and here is one part of the code. I have attached the whole code here in attacchment.
I am not able to figureout the logic behind the error.
The data file (excel) behind this code is attached here.
*snipped subfunction copied from inside interp1.m included as part of MATLAB*
here is the output:
What is the meaning of X and V?
I am new to app designing.
Error using interp1>reshapeAndSortXandV (line 423)
X and V must be of the same length.
Error in interp1 (line 92)
[X,V,orig_size_v] = reshapeAndSortXandV(varargin{1},varargin{2});
  3 comentarios
Walter Roberson
Walter Roberson el 19 de Abr. de 2023
You need to locate the call to interp1 and put a breakpoint at the beginning of the line that calls interp1 and then run the code. When the debugger stops because of the breakpoint, show us the line of code it is calling, and show us size() of each of the variables it mentions in the call to interp1()

Iniciar sesión para comentar.

Respuestas (1)

Walter Roberson
Walter Roberson el 19 de Abr. de 2023
For the purposes of interp1, x is the independent variable, and v is the corresponding dependant value.
For example you might have 50 times, but only have 49 acceleration readings.
The number of independent values must be the same as the number of dependent values.
  1 comentario
Steven Lord
Steven Lord el 19 de Abr. de 2023
As a general rule of thumb, an error message from a MathWorks function will refer to an input argument to that function by position (first argument, second argument, etc.) or by the name used in the help text and documentation for that function. In this case the documentation for the interp1 function uses x and v in the Syntax, Description, and Input Arguments sections.
And Walter is correct. There's a mismatch between the number of sample points and sample values.
x = [1 2 3 4 5];
v = [1 4 9 16 ]; % Whoops, forgot the 25
interp1(x, v, 2.5) % Will throw this error
Error using interp1>reshapeAndSortXandV
X and V must be of the same length.

Error in interp1 (line 128)
[X,V,orig_size_v] = reshapeAndSortXandV(X,V);

Iniciar sesión para comentar.

Categorías

Más información sobre Data Import from MATLAB en Help Center y File Exchange.

Productos


Versión

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by