CAT arguments dimensions are not consistent (in real time)

조회 수: 4 (최근 30일)
francisco gonzalez
francisco gonzalez 2015년 6월 1일
댓글: Walter Roberson 2015년 6월 1일
Hi all, i am trying to concatenate two arrays in real time. Looks like that the variable of array one appears first that the variable of array two, and for this situation, Matlab said me:
"CAT arguments dimensions are not consistent"
In real time, i have array A, that each 3 minutes has a new variable. In real time, i have array B, that each 3 minutes has a new variable.
I need to create the array P=[A B], but in one moment, the array A or B have not the same size that the other array (A or B). How can i solve this problem?
Thank you very much
  댓글 수: 2
Image Analyst
Image Analyst 2015년 6월 1일
Let's say that A is a 3x3 matrix, and B is a 100 by 100 matrix. How do you want to stitch them together? Do you want to pad the smaller matrix with zeros until it matches the number of rows in the larger matrix? Or do you want to do something else?
francisco gonzalez
francisco gonzalez 2015년 6월 1일
Hi, thank you very much for your reply. Well, one array (A) has one column and 500 rows. Two array (B) has one column and 500 rows too. The array P, concatenate both arrays Then, each 3 minutes, in both arrays entry one variable, but when matlab read, for seconds, one array still not enter the variable. So, for few time, array A has different size of array B, and when matlab read P=[A B]: "CAT arguments dimensions are not consistent"
I dont know how can i solve this problem, because at instant of time, the arrays have different size in real time.

댓글을 달려면 로그인하십시오.

답변 (1개)

Image Analyst
Image Analyst 2015년 6월 1일
If all arrays have 500 rows and 2 dimensions, then you would not get an error. What are the sizes when it throws an error? Use a try catch
try
% Code that produces an error
P=[A, B];
catch ME
errorMessage = sprintf('Error in program %s, function %s(), at line %d.\n\nError Message:\n%s', ...
mfilename, ME.stack(1).name, ME.stack(1).line, ME.message);
fprintf(1, '%s\n', errorMessage);
uiwait(warndlg(errorMessage));
end
Set a breakpoint at the uiwait() and then examine the sizes of A and B at that time.
  댓글 수: 6
Image Analyst
Image Analyst 2015년 6월 1일
I suggest that perhaps you just check the sizes and if they don't have the same number of rows, skip that iteration, figuring that it's just corrupt/partial data.
Walter Roberson
Walter Roberson 2015년 6월 1일
Depending on how you receive your data, you may be able to wait for both new values to be available. But you should always be aware of the possibility that the device is going to send the wrong amount of data, and plan for what should happen if that occurs.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by