|
173 | 173 | endif |
174 | 174 |
|
175 | 175 | for idx=1:prop_idx-1 |
| 176 | + |
| 177 | + if isstruct(varargin{idx}) |
| 178 | + error ("dbtable doesnt support columns of structs"); |
| 179 | + endif |
| 180 | + |
176 | 181 | n = inputname(idx); |
177 | 182 | if isempty(n) |
178 | 183 | n = sprintf("Var%d", idx); |
@@ -252,7 +257,7 @@ function disp (this) |
252 | 257 | if iscell(d) |
253 | 258 | d = d{1}; |
254 | 259 | endif |
255 | | - if !ischar(d) |
| 260 | + if !isnumeric(d) |
256 | 261 | d = num2str(d); |
257 | 262 | endif |
258 | 263 | w = length(d); |
@@ -491,33 +496,41 @@ function summary (this) |
491 | 496 | %! assert(t{1,1}, [0]); |
492 | 497 | %! assert(t{1,2}, [2]); |
493 | 498 | %! |
494 | | -%! assert(t(:,:), {[0;1;3], [2;4;6]}); |
495 | | -%! assert(t(1,:), {[0], [2]}); |
496 | | -%! assert(t(1,1), [0]); |
497 | | -%! |
498 | 499 | %! t.Properties.Description = "Test data"; |
499 | 500 | %! |
500 | 501 | %! t.Properties.VariableNames = {'V1', 'V2'}; |
501 | 502 | %! assert(t.V1, [0;1;3]); |
502 | 503 | %! assert(t.V2, [2;4;6]); |
503 | 504 |
|
| 505 | +%!test |
| 506 | +%! t = dbtable([0;1;3], [2;4;6]); |
| 507 | +%! assert(istable(t)); |
| 508 | +%! t1 = t(:,:); |
| 509 | +%! assert(istable(t1)); |
| 510 | +%! assert(size(t1), [3 2]) |
| 511 | +%! assert(t1{:,:}, {[0;1;3], [2;4;6]}); |
| 512 | +%! |
| 513 | +%! t1 = t(:,1); |
| 514 | +%! assert(istable(t1)); |
| 515 | +%! assert(size(t1), [3 1]) |
| 516 | +%! assert(t1{:,:}, [0;1;3]); |
| 517 | +%! |
| 518 | +%! t1 = t(:,2); |
| 519 | +%! assert(istable(t1)); |
| 520 | +%! assert(size(t1), [3 1]) |
| 521 | +%! assert(t1{:,:}, [2;4;6]); |
| 522 | +%! |
| 523 | +%! t1 = t(1,:); |
| 524 | +%! assert(istable(t1)); |
| 525 | +%! assert(size(t1), [1 2]) |
| 526 | +%! assert(t1{:,:}, {[0], [2]}); |
| 527 | + |
504 | 528 | %!test |
505 | 529 | %! t = dbtable([0;1;3], [2;4;6]); |
506 | 530 | %! assert(size(t), [3 2]); |
507 | 531 | %! tc = dbtable(t); |
508 | 532 | %! assert(size(tc), [3 2]); |
509 | 533 |
|
510 | | -%!test |
511 | | -%! d = struct; |
512 | | -%! d.name = { 'Name1';'Name2'; 'Name3' }; |
513 | | -%! d.age = [ 30; 21; 17]; |
514 | | -%! d.enrolled = { 1 [] 0 }; |
515 | | -%! d.nullstr = { "S1"; []; "s3" }; |
516 | | -%! t = dbtable(d); |
517 | | -%! assert(size(t), [3 4]); |
518 | | -%! assert(t.Properties.VariableNames, {'name', 'age', 'enrolled', 'nullstr'}); |
519 | | -%! assert(t.age, d.age); |
520 | | - |
521 | 534 | %!test |
522 | 535 | %! V1 = [0;1;3]; |
523 | 536 | %! V2 = [2;4;6]; |
|
0 commit comments