Getting error Error using / Matrix dimensions must agree.
1 次查看(过去 30 天)
显示 更早的评论
I am running my code effectively but as soon I introduce N2 P2 C2 as 1x1000 size array it gives me error. I intend to run my iterations for random values of these three and see best output .
1 个评论
Jan
2015-11-5
Please post the complete error message. It is much easier to suggest a solution if we do not have to search for the line, which causes the error.
If you omit the dull clear all debugging would be much easier.
回答(1 个)
Adam
2015-11-5
(N/(N2+N))
in your definition of X is causing the problem.
You are trying to divide a scalar by a 1x1000 array.
If you want to divide the scalar by all elements of the array then you need to use
(N./(N2+N))
If that isn't your intention then you need to work out what you do intend for that.
It is probably that some of your other functions run into similar problems.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!