How to store values as array
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
James Crowe
il 26 Ott 2017
Modificato: per isakson
il 26 Ott 2017
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
0 Commenti
Risposta accettata
per isakson
il 26 Ott 2017
Modificato: per isakson
il 26 Ott 2017
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 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Loops and Conditional Statements in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!