Can someone help me? Am getting the following error.
Mostra commenti meno recenti
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 Commenti
Rik
il 8 Mag 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.
John Amakali
il 8 Mag 2018
Risposte (3)
KSSV
il 8 Mag 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.
1 Commento
John Amakali
il 8 Mag 2018
John Amakali
il 8 Mag 2018
0 voti
3 Commenti
Dennis
il 8 Mag 2018
d=[d; data_sensor]; %does not work
d=[d;data_sensor{1,1}] %would work
d=[d;data_sensor{1,1};data_sensor{1,2}] %would work
John Amakali
il 8 Mag 2018
Dennis
il 8 Mag 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.
John Amakali
il 8 Mag 2018
Categorie
Scopri di più su Time Series Events in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!