MATLAB Answers

0

Why can't I assign a number in a matrix ?

Asked by kun wang on 23 Apr 2019
Latest activity Commented on by Adam Danz
on 29 Apr 2019
Screen Shot 2019-04-23 at 11.08.15 AM.png Screen Shot 2019-04-23 at 11.09.05 AM.png

  1 Comment

Your variable "totalcost1" appears to contain only one row and you're trying to access the second row which doesn't exist. I could go into more detail if there were code I could copy-paste but there's only an image that I can't copy from).
To see the number of rows and the number of columns in totalcost1: size(totalcost1)
Also, I doubt you want to hard-code the totalcost = 0 within your loop.

Sign in to comment.

0 Answers