How to do what MATLAB does with array[index:index] in Maxima?

1 回表示 (過去 30 日間)
Sidra Kiyani
Sidra Kiyani 2021 年 12 月 28 日
回答済み: KSSV 2021 年 12 月 28 日
I can't figure out how to dynamically take a portion at a time of a column vector in Maxima; for example I have the vector v = [a, b, c, d, e] and I want to take this: [a], [a, b], [a, b, c], etc. How can you do this in Maxima?

回答 (1 件)

KSSV
KSSV 2021 年 12 月 28 日
v = [1 2 3 4 5] ;
N = length(v) ;
iwant = cell(N,1) ;
for i = 1:N
iwant{i} = v(1:i) ;
end
celldisp(iwant)
iwant{1} = 1 iwant{2} = 1 2 iwant{3} = 1 2 3 iwant{4} = 1 2 3 4 iwant{5} = 1 2 3 4 5

カテゴリ

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

タグ

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by