I use the following codes to get a row vector and then unique it. But the answer is wrong.
Following is part of the answer:
-1.50000000000000 -1.25000000000000 -1.25000000000000 -1 -1.00000000000000 -1.00000000000000 -0.750000000000000 -0.750000000000000 -0.750000000000000 -0.750000000000000 ...
The result is definitely wrong. But I cannot find where the problem is. I'm a little crazy...
Anyone helps me is greatly appreciated.
No products are associated with this question.
If that was how you unique, you did not call it correctly. If you want to know everything about the unique rows of u, call it as:
[C,ia,ic] = unique(u,'rows');
The documentation explains the three outputs and how to use them.
Your vector u turns out to be a row vector, so to call unique using the 'rows' argument, transpose it:
v=3; alpha=0.5; i=1; for a=0:0.1:v for b=0:0.1:3-a x1=a; x2=b; x3=3-a-b; u(i)=x1-alpha*(x2-x1)-alpha*(x3-x1); i=i+1; end end
[C,ia,ic] = unique(u','rows');
Play games and win prizes!Learn more