как получить векторный массив выходных данных цикла for
56 views (last 30 days)
Show older comments
Pavel Kuzmitsky
on 28 Oct 2020
Commented: Pavel Kuzmitsky
on 1 Nov 2020
как извлечь из цикла все выходные данные в виде векторного массива?
например:
for n=1:3
y=2*n;
end
хочу получить после завершения цикла массив x=[2 4 6] но непонимаю как
0 Comments
Accepted Answer
madhan ravi
on 28 Oct 2020
n = 1 : 3;
for k = 1 : numel(n)
y(k) = 2*n(k);
end
3 Comments
madhan ravi
on 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)
More Answers (0)
See Also
Categories
Find more on Manage Products in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!