필터 지우기
필터 지우기

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