Can someone help me? Am getting the following error.
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Error using vertcat Dimensions of matrices being concatenated are not consistent. Error in GUI>pushbutton1_Callback (line 144)
part of the code: while(i<=numberOfDatas)
q = fscanf(s, '%f');
Tdata=[Tdata(2:end), q]; %Get the data from the serial object
set(M,'Zdata',[Tdata; zeroIndex],'Cdata',[Tdata; Tdata]);
drawnow;
c=round(clock);
data_sensor{1,1}=strcat(num2str(c(4)),...
':',num2str(c(5)),':',num2str(c(6))); %Current Time no. data conversion to string for Excel export
data_sensor{1,2}=q;
d=[d; data_sensor]; %Append new data to previous data matrix
i=i+1; %Increment the counter
end
if true
% code
end
2 comentarios
Rik
el 8 de Mayo de 2018
The answer is in the error text: you are concatenating several variables in this code snippet, and one of those don't fit. Use the debugger to stop on error (you can type dbstop if error to enable it). Then you can see the sizes of the arrays you're trying to concatenate and see how those don't fit. Then you can modify your code accordingly.
Respuestas (3)
KSSV
el 8 de Mayo de 2018
YOu cannot append two arrays with different dimensions....check below:
[rand(1,3) rand(4,1)] % it throws error.
[rand(1,3) rand(1,4)] % no error
[rand(3,1) ; rand(4,1)] % no error
You check for such a situation in your code.
John Amakali
el 8 de Mayo de 2018
3 comentarios
Dennis
el 8 de Mayo de 2018
I do not know what size Tdata or zeroIndex have. I could guess that they do not have the same length so [Tdata;zeroIndex] throws out an error. But without information about Tdata,q and zeroIndex its just a guess.
Ver también
Categorías
Más información sobre Logical 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!