как получить векторный массив выходных данных цикла for
135 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Pavel Kuzmitsky
le 28 Oct 2020
Commenté : Pavel Kuzmitsky
le 1 Nov 2020
как извлечь из цикла все выходные данные в виде векторного массива?
например:
for n=1:3
y=2*n;
end
хочу получить после завершения цикла массив x=[2 4 6] но непонимаю как
0 commentaires
Réponse acceptée
madhan ravi
le 28 Oct 2020
n = 1 : 3;
for k = 1 : numel(n)
y(k) = 2*n(k);
end
3 commentaires
madhan ravi
le 29 Oct 2020
You definitely didn't understand properly, anyway you don't need a loop:
k = 3;
v = -2 : 2;
R = sum(v( : ) .^ ( 0 : k), 2)
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!