Info

此问题已关闭。 请重新打开它进行编辑或回答。

Could anyone help me to solve the issue in the following code:

1 次查看(过去 30 天)
code:
a=[4.1288 5.2574 0 4.9757 3.0069;
0 3.7672 4.7411 3.4989 0;
4.7132 0 4.0136 0 4.9751]
siz = size(a)
result1=randi(3,1,5)
val_list=1:3
while ~all(ismember(val_list,result1))
result1=randi(3,1,5)
end
idx1 = sub2ind(siz, result1, 1:siz(2))
C1 = zeros(siz)
C1(idx1) = a(idx1)
D=sum(C1,2)
When i run the code it executes and gives me the result.
But what i actuallu need is with respect to the command line
C1(idx1) = a(idx1)
i need to have one nonzero value with respect to every row and column.
But when i run the code it gives me the result in such a way all values in any of the row or column becomes zero.
Could anyone please help me on this.
  2 个评论
Rik
Rik 2019-6-5
Only two hours passed between you posting this question and concluding that you don't get an answer. If your work is so time-sensitive and important that you can't wait, why don't you hire a consultant to do this?

回答(0 个)

此问题已关闭。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by