Re: syntax again!
- From: "Michael Robbins" <michaelNOrobbins@xxxxxxxxxxx>
- Date: Thu, 28 Jul 2005 19:12:25 -0400
> 1) sample([1:4,[1:4])=x([1:3],[1:3]);
This is a little odd, I think you miss-typed it. The RHS (right hand
side) says take the upper left 9 numbers (3x3) from matrix "x" and
put them in...
But the left side is incorrect, maybe it should read
"sample([1:4],[1:4])?" But that would be odd, because it'd be
difficult to put 9 items (3x3) into 16 spaces (4x4).
Also, the square brackets are superfluous so I expect the author
wasn't an expert at MATLAB.
> 2) sample([1:4],[1:4])=sample>100;
The RHS says fill a 1xn array with zeros and ones, where the ones
represent when sample(i)>100 and zeros where sample(i)<=100.
For example,
sample = [12 100 110 90 101];
sample>100 would yield "0 0 1 0 1"
Note also that an N dimensional matrix can be represented as a 1xM
array:
sample = [100 101; 99 110] looks like
100 101
99 110
but that same array, re arranged in 1D format, by typing "sample(:),"
looks like
100 101 99 110
So, "sample(:)>100" gives "0 1 0 1."
Check out my examples for your benefit at
<http://www.mathworks.com/matlabcentral/fileexchange/loadFileList.do?objectType=fileexchange&orderBy=date&srt3=0>
.
- References:
- syntax again!
- From: rina rao
- syntax again!
- Prev by Date: Re: How to integrate a function from -inf to a ?
- Next by Date: Re: Matching Pairs (playing with arrays)
- Previous by thread: syntax again!
- Next by thread: q: fminunc() problem
- Index(es):
Relevant Pages
|