CAT arguments dimensions are not consistent (in real time)
Show older comments
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
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
on 1 Jun 2015
Answers (1)
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
francisco gonzalez
on 1 Jun 2015
Image Analyst
on 1 Jun 2015
Well, I guess A really doesn't have 99 rows, or 500 rows, does it? It has only 9 rows. Why? I have no idea. Only you know where they came from.
Walter Roberson
on 1 Jun 2015
You started the example with A being 99 rows, but below that you show A with 9 rows.
francisco gonzalez
on 1 Jun 2015
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
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.
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!