How can i combined array automatically

2 ビュー (過去 30 日間)
Triveni
Triveni 2016 年 5 月 18 日
編集済み: Stephen23 2016 年 5 月 18 日
a = [100, 125, 150, 175, 200, 225, 250, 275, 300, 325];
for k = 1: numel(a)
Fx{:,:,k} = a(k:numel(a))
end
Tx = [Fx{:,:,1},Fx{:,:,2},Fx{:,:,3},Fx{:,:,4},Fx{:,:,5},Fx{:,:,6},Fx{:,:,7},Fx{:,:,8},Fx{:,:,9},Fx{:,:,10}];
i want to generate Tx automatically without manual input

採用された回答

Stephen23
Stephen23 2016 年 5 月 18 日
編集済み: Stephen23 2016 年 5 月 18 日
>> tmp = a(:)*ones(1,numel(a));
>> Tx = tmp(tril(true(numel(a))))
Tx =
100
125
150
175
200
225
250
275
300
325
125
150
175
200
225
250
275
300
325
150
175
200
225
250
275
300
325
175
200
225
250
275
300
325
200
225
250
275
300
325
225
250
275
300
325
250
275
300
325
275
300
325
300
325
325
>>
  2 件のコメント
Triveni
Triveni 2016 年 5 月 18 日
If i want to combined only
Tx = [Fx{:,:,2},Fx{:,:,3},Fx{:,:,4},Fx{:,:,5},Fx{:,:,6},Fx{:,:,7},Fx{:,:,8},Fx{:,:,9},Fx{:,:,10}];
means 2:10 or 3:10 or 3:9 then??
Stephen23
Stephen23 2016 年 5 月 18 日
編集済み: Stephen23 2016 年 5 月 18 日
I have no idea what you mean with "means 2:10 or 3:10 or 3:9 then??"
However if you are interested in taking only some of the sequence, then have a play around with the indexing:
>> tmp = a(:)*ones(1,numel(a));
>> idx = tril(true(numel(a)));
>> N = 2; % change this! 1, 2, 3, 4, 5, etc
>> idx(:,1:N-1) = false;
>> Tx = tmp(idx)
Tx =
125
150
175
200
225
250
275
300
325
150
175
200
225
250
275
300
325
175
200
225
250
275
300
325
200
225
250
275
300
325
225
250
275
300
325
250
275
300
325
275
300
325
300
325
325
>>

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDates and Time についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by