Info
此问题已关闭。 请重新打开它进行编辑或回答。
If I have a vector S=[4 1 2 2 1 1 1 1 1 1] and I want to generate all possible matrices C with dim(10*10) with a condition that [C(i,:)+C(:,i)=S(1,i)] and the values in C are wanted to be integer (0,1,2,...)
1 次查看(过去 30 天)
显示 更早的评论
If I have a vector S=[4 1 2 2 1 1 1 1 1 1] and I want to generate all possible matrices C with dim(10*10) with a condition that [C(i,:)+C(:,i)=S(1,i)] and the values in C are wanted to be integer (0,1,2,...)
4 个评论
Guillaume
2017-6-3
In matlab <R2016b, C(i, :) + C(:,i) is an error.
In matlab R2016b and later, C(i, :) + C(:, i) results in a 10x10 matrix.
So as John said, you need to explain CLEARLY what it is you want, using valid matlab syntax.
John D'Errico
2017-6-3
编辑:John D'Errico
2017-6-3
If you add two vectors (of the same length and shape) together, the result is a vector. So unless you also mean to sum the result, then as I said, your expression has no meaning.
If the goal is to solve this problem, where you also SUM those vectors (or something like that) then computing ALL possible such 10x10 arrays will be highly computationally intensive. And since everybody always really wants to solve much bigger problems than the examples they show, you will need to get a seriously big and fast computer.
Think of it like this: you have 100 unknown elements in that array. In this case, some of those elements may be as large as 4. So some elements may be as small as zero, or as large as 4.
So you will need to find ALL possible sets of 10x10 elements that satisfy the requirements. Depending on S, that may involve search a space of size
5^100
ans =
7.8886e+69
possible arrays. That is a moderately large number.
seven duovigintillion, eight hundred eighty eight unvigintillion, six hundred vigintillion
While it is true that many of the possible arrays can be dismissed immediately, a computer can not know that in advance. And of course, if your real problem is bigger than the example you show, you may well need a computer the size of the universe to solve it.
回答(0 个)
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!