Can someone help me? Am getting the following error.
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Rik
le 8 Mai 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.
Réponses (3)
KSSV
le 8 Mai 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
le 8 Mai 2018
3 commentaires
Dennis
le 8 Mai 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.
Voir également
Catégories
En savoir plus sur Structures dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!