CAT arguments dimensions are not consistent (in real time)

4 views (last 30 days)
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 Comments
Image Analyst
Image Analyst on 1 Jun 2015
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 on 1 Jun 2015
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.

Sign in to comment.

Answers (1)

Image Analyst
Image Analyst on 1 Jun 2015
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 Comments
Image Analyst
Image Analyst on 1 Jun 2015
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 on 1 Jun 2015
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.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!