Dimensions of matrices being concatenated are not consistent ?
2 次查看(过去 30 天)
显示 更早的评论
% 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
0 个评论
采纳的回答
madhan ravi
2020-7-12
编辑:madhan ravi
2020-7-12
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 个评论
更多回答(1 个)
Walter Roberson
2020-7-12
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Characters and Strings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!