Error using plot Vectors must be the same length.
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Govind Sankar Madhavan Pillai Ramachandran Nair
el 16 de Ag. de 2023
Respondida: Steven Lord
el 16 de Ag. de 2023
I am trying to plot this.
plot(time,cellvoltages).
Size of cellvoltages is 36004 x 84.
That is fixed. Now the time varies according what we give. So Time is found out using a series of lines of code.
time_sec = (1:len_dataset)*dt;
time = time_sec/3600;
len_dataset is 36004. That is fixed. dt is what we give. So if we give dt as something less than 1 for eg 0.5 then plot works perfectly. The size of time in that case is 1 x 501. But if we give dt more than 1 say 1.25 then its giving an error
Error using plot
Vectors must be the same length.
This size of time now is 1 x 28800.
What is the cause of this error. Can anyone help me. Thank you.
6 comentarios
Dyuman Joshi
el 16 de Ag. de 2023
[index_min, index_max] = find_time_index(time, TIME_MIN, TIME_MAX);
if index_min < 1
index_min = 1;
end
time = time(index_min:index_max);
This snippet of code does not make sense to me.
Maybe you can attach the part of the code that is relevant to the problem you are facing.
Without the working code, it is difficult to suggest anything.
Respuestas (1)
Steven Lord
el 16 de Ag. de 2023
You can create a vector in MATLAB using any three of the four pieces of data starting point, ending point, space between points, and number of points. In this case you're using the first three of those pieces of data but then the number of points may not be what you want. In that case I'd use the starting and ending points and the desired number of points instead
Define data
startpoint = 1;
endpoint = 10;
spacing = 0.5;
numpoints = 19;
Start, end, space
A1 = startpoint:spacing:endpoint
Start, end, number
A2 = linspace(startpoint, endpoint, numpoints)
Start, spacing, number
A3 = startpoint + spacing*(0:numpoints-1)
End, spacing, number
A4 = -spacing*flip(0:numpoints-1) + endpoint % Work backwards
Check
isequal(A1, A2, A3, A4)
0 comentarios
Ver también
Categorías
Más información sobre Measurements and Feature Extraction 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!