Info

この質問は閉じられています。 編集または回答するには再度開いてください。

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

1 回表示 (過去 30 日間)
jaah navi
jaah navi 2019 年 6 月 5 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
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 件のコメント
jaah navi
jaah navi 2019 年 6 月 5 日
As no answers were provided i made it in different way.
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