フィルターのクリア

How do I create a header with many elements, but has function outputs in it as well?

2 ビュー (過去 30 日間)
Tony
Tony 2016 年 3 月 10 日
コメント済み: Tony 2016 年 3 月 11 日
I am trying to create a header for a large matrix. The matrix looks something like this:
A =
[100, 101, 102, ..., 999
990, 454, 565, ..., 453
. . . , ..., .
. . . , ..., .
some numbers , ..., 345]
num = [100 101 102 ... 999]
I also have an array that counts occurrences of specific elements in each column.
number = [4 6 7 5 ... 3] where there are 900 elements in this array
I would like to create a header so the output looks like this:
[100=4, 101=6, 102=7, ..., 999=something
100, 101, 102, ..., 999
990, 454, 565, ..., 453
. . . , ..., .
. . . , ..., .
some numbers , ..., 345]
I have tried
for idx = 1:length(num)
header{idx} = num(idx) '=' number(idx)};
end
but I am really confused on the syntax for this and when I want to combine the header with A.

採用された回答

Walter Roberson
Walter Roberson 2016 年 3 月 10 日
for idx = 1:length(num)
header{idx} = sprintf('%d = %d', num(idx), number(idx));
end
result = [header; num2cell(A)];

その他の回答 (0 件)

カテゴリ

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