Hello World. So, I am new to programming entirely, let alone Matlab. I know it i
ID: 1924964 • Letter: H
Question
Hello World.
So, I am new to programming entirely, let alone Matlab. I know it is trivial and that there are other ways of going about this- but I was wondering how to index even numbers.<br /><br />I know that you can index odd numbers, for example the following would return the square of the first 10 odd numbers:</p>
for i=1:2:20
x(i)=sqrt(i)
end
However, I do not know why this returns the odd index values- I just know it does.
I am working ahead on our lab for tomorrow, and don't have Matlab on my computer. I'm working on installing Octave right now. However, I am more focused on the theory and understanding of the notation and language.
Thanks in advance,
Kitteh Guy
Explanation / Answer
First understand what you mean when you write this
syntax
For i = 1:2:20
in this for statement you have three important numbers, the first (here 1) is the starting value, the third (here 20) is the ending value, and the middle one (here 2) is the increment to be given. So when you write that for statment you are already supplying the odd values of the indices.
PS: i was not able to make this much sense of your question, If you have any other query regarding this question then please enter it in the comments, I would edit my answer accordingly thanks
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.