How to obtain the result of an operation in a vector

2 次查看(过去 30 天)
What I must do is place the result of this summation inside a vector so that I do not get disordered but I can not find the way to do it. I have something like this
for i = -100:100
x = exp(i)
i
end
  2 个评论
Stephen23
Stephen23 2019-2-7
编辑:Stephen23 2019-2-7
"What I must do is place the result of this summation inside a vector"
What summation? There is no sum or anything like a sum in your code.
In any case, you either need to store the output using indexing, or write vectorized code:
x = exp(-100:100)
Very basic MATLAB concepts, such as how to use loops and indexing to store values, are explained in the introductory tutorials:
Dionisio Mendoza
Dionisio Mendoza 2019-2-7
youre rigth i was wrong of excersice, but in that example were i put the vectorized code? sorry im very rookie

请先登录,再进行评论。

回答(1 个)

madhan ravi
madhan ravi 2019-2-7
编辑:madhan ravi 2019-2-9
sum(exp(-100:100))

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by