The awnser ended up being

4 views (last 30 days)

I have been looking through the community for the awnser to this since it has been brought up so much, and it has helped me alot, but I'm missing something and dont know what keywords to use to find it.

I'm trying to sum the rows of my vector x but the current code does not seem to do this, I think it an error with n=50:1 but dont know what else todo.

the cyclist
on 25 Mar 2020

Edited: the cyclist
on 25 Mar 2020

If you type the expression

50:1

into MATLAB, you will get the result

>> 50:1

ans =

1×0 empty double row vector

So, your for loop doesn't have any iterations.

You could try

for n = 1:50

instead.

Also, note that

sum(x(1:50))

will sum the first 50 elements of x, without a for loop, and

sum(x)

will sum all the elements of x.

Seems like you might benefit from a beginners tutorial in MATLAB. You might want to take a look at the MATLAB Onramp.

the cyclist
on 25 Mar 2020

Sign in to comment.

Sign in to answer this question.

Opportunities for recent engineering grads.

Apply Today
## 0 Comments

Sign in to comment.