How to obtain the result of an operation in a vector

조회 수: 2 (최근 30일)
Dionisio Mendoza
Dionisio Mendoza 2019년 2월 7일
편집: madhan ravi 2019년 2월 9일
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에서 Just for fun에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by