How to store values as array

2 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by