Can someone help me? Am getting the following error.
2 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
Rik
2018 年 5 月 8 日
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.
回答 (3 件)
KSSV
2018 年 5 月 8 日
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
2018 年 5 月 8 日
3 件のコメント
Dennis
2018 年 5 月 8 日
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.
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!