[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: How to check & insert max values into a matrix?
From: |
Hall, Benjamin |
Subject: |
RE: How to check & insert max values into a matrix? |
Date: |
Mon, 17 Jul 2006 12:40:25 -0400 |
> That I understand, but how to use a second matrix and do
> the same thing entry by entry?
>
> >> mymatrix( mymatrix .< secondmatrix ) .= secondmatrix;
>
You have to make the "stuff" on the rhs of the equal sign the same size as
the "stuff" on the lhs, for example:
octave:7> a = rand(4,4)
a =
0.934775 0.401068 0.974327 0.841767
0.042087 0.325470 0.656502 0.711730
0.519402 0.714157 0.855209 0.522446
0.844893 0.789146 0.167678 0.271139
octave:8> b = rand(4,4)
b =
0.142786 0.040289 0.152776 0.632984
0.953375 0.014280 0.766084 0.582438
0.577141 0.962024 0.637831 0.051329
0.659995 0.504942 0.606603 0.061225
octave:9> a(a<b) = b(a<b)*10, ## Multiply by 10 to make it easier to
see what's replaced
a =
0.93477 0.40107 0.97433 0.84177
9.53375 0.32547 7.66084 0.71173
5.77141 9.62024 0.85521 0.52245
0.84489 0.78915 6.06603 0.27114