CAT arguments dimensions are not consistent (in real time)
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Image Analyst
el 1 de Jun. de 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?
Respuestas (1)
Image Analyst
el 1 de Jun. de 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 comentarios
Image Analyst
el 1 de Jun. de 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
el 1 de Jun. de 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.
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!