How to store values as array

1 回表示 (過去 30 日間)
James Crowe
James Crowe 2017 年 10 月 26 日
編集済み: per isakson 2017 年 10 月 26 日
How do you store all k values as a single array?
for ii = nn
k = ((-1).^(ii-1)).*((xx^(2.*(ii-1))))./(factorial(2.*(ii-1)));
end

採用された回答

per isakson
per isakson 2017 年 10 月 26 日
編集済み: per isakson 2017 年 10 月 26 日
There are a couple of mistakes in your code. Try this
k = nan( 1, nn ); % pre-alloctate memory
for ii = 1 : nn
k(ii) = ((-1).^(ii-1)).*((xx^(2.*(ii-1))))./(factorial(2.*(ii-1)));
end
assert( all(not(isnan(k))) )

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by