Error using ==> plot Vectors must be the same lengths.
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
What if you have two vectors. let's say A size is 1200 x 1 and B size is 4 x 1... B is timestamp of each file processed in a directory.. meaning each file has 300 samples in it i.e 1200/4 gives you only 4 diff timestamps. what if i want plot(B,A) for that the timestamp would display every 300 samples on the x axis. of course when i tried to do it with my code i get this error: Error using ==> plot Vectors must be the same lengths.
filedir = dir(dirpath)
timerArray=[];
Array=[];
for cnt=1:length(filedir)
timerArray=vertcat(timerArray, (filedir(cnt).datenum));
data=fread(fid,[rows,cols],'double')
Array=horzcat(Array, data);
plot(timerArray,Ex)
datetick('x' , 13 , 'keeplimits')
end
part of the code if there are errors it might because i was cropping the most relevant part of the code for the question.
0 comentarios
Respuestas (1)
Walter Roberson
el 14 de Mayo de 2014
How many output lines are expected? 1 or 4 or 300?
Is A(2) to be considered to be at a different time than A(1)? If so then are the times for A(1:301) to be equally distributed over the time range between B(1) and B(2)? And A(301:601) times to b equally distributed over the time range B(2) to B(3) ? If so then what is the final time for A(1200) as there is no B(5) to know the interpolation?
Or is there a fixed interval between A(1) and A(2) that is the same as the interval between A(301) and A(302)? Is the time associated with A(300) by the fixed interval potentially more than one tick before B(2) [leaving a gap] or potentially after B(2) [making an overlap] or is B(2) certain to be exactly right to be one tick after the time associated with A(300)?
Could it be that there is a continuous time base like above, and the times in B are merely the times you want to be specifically labelled ?
If that is the case, that B tells you where to label, then you need to create a time vector, T, giving the time associated with each element of A, and then you
plot(T, A);
set(gca, 'XTick', B)
3 comentarios
Ver también
Categorías
Más información sobre Line Plots en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!