Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Matrix manipulation problem under MATLAB and swapping values

조회 수: 1 (최근 30일)
dakhli mohamed
dakhli mohamed 2018년 11월 8일
마감: MATLAB Answer Bot 2021년 8월 20일
Hi, I have a starting matrix sw =
0.0890 0.5520 0.4880
0.3980 0.3390 0.3860
0.2030 0.2870 0.2950
and I have two classes in this matrix I made a growing sort of the first class and I put them in L1 and descending sort of the second class and I put them in L2 %%I replace the values of the second class with 0's
L1=
0
0
0.287
0.295
0.339
0.386
0.398
0.488
0.552)
and
L2 =
0.203
0.089
0
0
0
0
0
0
0
if L1(1)<L2(1) %%(L1 (1): This is the first element of the L1 list)
so I swap the values in the starting matrix

답변 (1개)

madhan ravi
madhan ravi 2018년 11월 8일
편집: madhan ravi 2018년 11월 8일
sw = [0.0890 0.5520 0.4880
0.3980 0.3390 0.3860
0.2030 0.2870 0.2950]
L1= [0 0 0.287 0.295 0.339 0.386 0.398 0.488 0.552]
L2 = [0.203 0.089 0 0 0 0 0 0 0]
L1([1 2]) = L1([2 1]) %example of swapping elements
  댓글 수: 6
Guillaume
Guillaume 2018년 11월 8일
What if both of L2 values are larger than the minimum of L1?
dakhli mohamed
dakhli mohamed 2018년 11월 8일
I make the comparison only with great value and in an iterative way I am looking for the second small value of class 1 and I compare it with the 2nd big value of class 2 And so on

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by