Referring to problem:
https://www.mathworks.com/matlabcentral/cody/problems/44530-are-you-more-familiar-with-iteration-methods-or-linear-algebra-let-s-see-together
Given a sum result x value of a N number of addends, build an array of N elements y such that the following equality is satisfied: sum(y) = x .
For example if: x = 10 and N = 2, possible solutions for y are: [7 3], or [8 2].
More formally if x = a and N = n it results:
y = [y_1 y_2 y_3 ... y_n] where: y_1 + y_2 + y_3 +...+ y_n = a
Important notice: All the elements in y must be: different from zero, different from each other and strictly positive . On the other hand I will not take into account if they are integers or decimal numbers .
Hint: You can use several approaches and the solution is not unique. For example you can think to approach with a iterative method or, if you are more accustomed with Algebra, by solving a linear system. This choice it's up to you.
Good luck and enjoy with the solution ;)
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers25
Suggested Problems
-
2364 Solvers
-
662 Solvers
-
Implement simple rotation cypher
1096 Solvers
-
Operate on matrices of unequal, yet similar, size
231 Solvers
-
Create a two dimensional zero matrix
527 Solvers
More from this Author1
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
There is a unique solution to the linear equations.
Dear Jia, the solution is not unique. I've upload a second one that is simpler and does not require to solve any linear system.
Dear Riccardo, It's a very interesting topic. It's a collection of notes.