Dimensions of matrices being concatenated are not consistent ?

1 view (last 30 days)
% How can I display the result in the following example. Not all time the strings are equals,
%but I need to display one below the other even at the end one even one is missing, it is possible?
c=[23;33;33;44;55;66;77;88;99;00;11;22;33;44];% 14 numbers
d=[23;33;33;44;55;66;77;88;34;00;11;44;33;44];% 14 numbers
e=[23;33;33;44;45;66;77;88;99;00;11;22;23;44];% 14 numbers
f=[23;33;33;44;53;66;77;88;99;04;11;22;33;44];% 14 numbers
g=[23;33;33;45;53;66;77;88;99;04;11;22;33;]; % as you can see this string is only 13 numbers
c=c';
d=d';
e=e';
f=f';
g=g';
result=[c;d;e;f;g];
Error:
Error using vertcat
Dimensions of matrices being concatenated are not consistent.
Error in Runscript (line 11)
result=[c;d;e;f;g];
%%I would like the result like in following picture below

Accepted Answer

madhan ravi
madhan ravi on 12 Jul 2020
Edited: madhan ravi on 12 Jul 2020
You cannot have holes in a matrix so append NaN at the end. By the way you refer to them as string but in fact they are double array. But if they were string appending "" at the end of g would do it.
  3 Comments

Sign in to comment.

More Answers (1)

Walter Roberson
Walter Roberson on 12 Jul 2020
I notice that you are using R2016a, so I will not mention some of the possibilities for later releases
You cannot do that with a numeric array.
If you convert it to a cell array of numbers, and leave some entries empty, then you can cell2table() and writetable()
You can use dlmwrite() with append set, to write one line of values at a time.
You can experiment with putting in nan for the entries that you want to be blank, and convert to table, and use writetable(). At some point, nan started being writen out as empty, but I am not sure how early that was.
If this is for uitable for display purposes, then you can create a cell array of character vectors, leaving some of the cells empty, and setting the uitable Data property to the cell. If you do this, then if you permit editing the user will be able to enter text instead of numeric; you will need to str2double() and check for nan if you accept input on the uitable.
You will not be able to do what you want with the Variable Brower.

Categories

Find more on Data Type Conversion in Help Center and File Exchange

Products


Release

R2016a

Community Treasure Hunt

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

Start Hunting!