CAT arguments dimensions are not consistent (in real time)

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

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?
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)

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

for this new example: A=(99 rows, 1 column); B=(99 rows, 1 column);
but time when matlab give me error:
"Error while evaluating TimerFcn for timer 'timer-1'
CAT arguments dimensions are not consistent."
A=(9 rows, 1 column); B=(99rows, 1 column);
i dont understand
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.
You started the example with A being 99 rows, but below that you show A with 9 rows.
It is rare. i see the arrays when the process stop for the error. Then A has 9 arrows and B has 99 arrows. I think that the process is interrupt and this is the result. The complete process is:
- I import real data of two different component (A, B)
- the array is supplied with new data every 3 minutes and always have to have 99 rows and 1 column in each array.
- when Matlab import new data, i need to build new array, P=[A B], and the size of this array would be 99 arrows and 2 columns.
I think that the data not import at the same time, ie, data for array A come at 3 minutes and data for array B come at 3 minute one second. This can to have that different size for construct P.
All this with GUI of Matlab
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.
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.

Categories

Asked:

on 1 Jun 2015

Commented:

on 1 Jun 2015

Community Treasure Hunt

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

Start Hunting!