【发布时间】:2015-12-05 05:37:14
【问题描述】:
我有以下矩阵。
Data = [
672 741 642 NaN 826 NaN NaN NaN NaN;
589 371 237 539 555 NaN NaN NaN NaN;
529 699 593 578 653 NaN NaN NaN NaN;
552 654 337 473 697 NaN NaN NaN NaN;
512 421 479 553 346 NaN NaN NaN NaN;
325 348 356 295 337 NaN NaN NaN NaN;
263 369 303 338 395 NaN NaN NaN NaN;
503 472 372 428 563 NaN NaN NaN NaN;
464 NaN 444 286 436 NaN NaN NaN NaN;
382 208 264 196 331 NaN NaN NaN NaN;
416 431 405 443 491 NaN NaN NaN NaN;
370 414 351 137 405 NaN NaN NaN NaN;
631 622 597 500 555 NaN NaN NaN NaN;
368 373 697 538 550 NaN NaN NaN 384;
467 446 463 361 406 NaN NaN NaN NaN;
398 457 461 376 469 NaN NaN NaN NaN
];
使用功能(我正在寻找)
c = number of columns desired
[idx_col] = select_cols(Data,3);
我想要没有 NaN 的最大行数的 Data 列的索引。
例如:
c = 3; % number of columns desired
[idx_col] = select_cols(Data,3);
idx_col{1} = 1,3,5 since they do not have NaN elements.
c=4
idx_col{1} = 1,2,3,5 (there is only row 9 with NaN)
and
idx_col{2} = 1,3,4,5 (there is only row 1 with NaN)
c=2
idx_col{1} = 1,3
and
idx_col{2} = 1,5
and
idx_col{3} = 3,5
【问题讨论】:
-
如果有关系呢?例如 c=7。或 c=2
-
@AnderBiguri 我添加了示例 c=2