How to: Matrix question empty column

4 ビュー (過去 30 日間)
Hello kity
Hello kity 2013 年 1 月 25 日
I want to make a matrix with inbetween empty columns.
so, column 1 and 2 have data, 3 is empty, 4 and 5 have data , 6 is empty.
AllData=[Data1, Data2, emptycolumn, Data3, Data4]
thank you

回答 (2 件)

Evgeny Pr
Evgeny Pr 2013 年 1 月 25 日
編集済み: Evgeny Pr 2013 年 1 月 25 日
This available only for cell arrays.
[] - (Empty) Already an array
Numeric arrays can not store any other empty numeric arrays.
a = [1 2 3 4 5]
a(1) = [] % delete item 1
a = [1 2 3 [] 4 5] % a = [1 2 3 4 5] (concatenation of arrays)
c = cell(5)
isempty(c{1})
c(:,1) = {10}
c(:,3) = {20}
c =
[10] [] [20] [] []
[10] [] [20] [] []
[10] [] [20] [] []
[10] [] [20] [] []
[10] [] [20] [] []

Thorsten
Thorsten 2013 年 1 月 25 日
Maybe you can achieve your goal by inserting columns of NaNs
X = ones(10);
X(:, [3 6]) = nan(10,2);

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by