From: Andy on
"Anthony Hopf" <anthony.hopf(a)gmail.com> wrote in message <i1iaj1$d8k$1(a)fred.mathworks.com>...
> But what if you want to replace the values?
>
> m(any(m ==0,2),:)=[1 1 1];
>
> This doesn't work, I get a dimension mismatch problem.
>
> Thank you


m=[
1 2 3
0 4 5
0 0 0
6 0 0
];
n = any(m==0,2);
m(n,:)=repmat([1 1 1],[sum(n) 1]);

You got dimension mismatch because you were trying to assign a 1x3 array to a 3x3 array. You need to ensure the data you're inserting is the same size as the data you're editing.
 | 
Pages: 1
Prev: GUI Variable Sharing
Next: bwarea