Prev: To find X at which Y is maximum
Next: graph drawing
From: mins alaa on 12 Apr 2010 06:49 I would like to generate a 15 * 20 random matrix ranging from -2 and 2, and then find the maximum and minimum values inside the matrix. Then using loops, set all matrix elements that exceed the value of 1.2 to the maximum while setting the elements below -1.2 to the minimum. Can someone help me please?
From: Ulf Graewe on 12 Apr 2010 07:08 "mins alaa" <zabola10(a)yahoo.com> wrote in message <hputqv$h6n$1(a)fred.mathworks.com>... > I would like to generate a 15 * 20 random matrix ranging from -2 and 2, and then find the maximum and minimum values inside the matrix. Then using loops, set all matrix elements that exceed the value of 1.2 to the maximum while setting the elements below -1.2 to the minimum. Can someone help me please? What have you done unitl now? Can you show a piece of code, and where you are stuck? In the worst case, the MATLAB documentation is always your friend! doc rand doc min doc max doc find
From: Luca Balbi on 12 Apr 2010 07:58 And unless you're forced to, don't use loops! mtx = 4*(rand(15,20)-0.5); valueMin = min(mtx(:)); valueMax = min(mtx(:)); mtx(mtx<-1.2) = valueMin; mtx(mtx>1.2) = valueMax;
|
Pages: 1 Prev: To find X at which Y is maximum Next: graph drawing |