问题
I've tried this:
linefunca = @(xa,ya) aa*xa + ba*ya + ca;
figure(1)
imshow(Pica);
hold on;
ezplot(linefunca,[1,1072,1,712]);
But I'm returned with this error:
In an assignment A(I) = B, the number of elements in B and I must be the same.
Error in ezplotfeval/applyfun (line 80)
z(i) = feval(f,x(i),y(i));
Error in ezplotfeval (line 65)
z = applyfun(x,y);
Error in ezplot>ezimplicit (line 257)
u = ezplotfeval(f, X, Y);
Error in ezplot (line 153)
hp = ezimplicit(cax, f{1}, vars, labels, args{:});
Error in ps3 (line 313)
ezplot(linefunca,[1,1072,1,712]);
aa
,ba
,ca
are all known values (column vectors). The x and y limits are the size of the image that I'm working with. I'm trying to plot a set of epipolar lines. Any suggestions?
EDIT:
lt = length(aa);
linefunca = @(x,y,t) aa.*x(t) + ba.*y(t) + ca(t);
figure(1)
imshow(Pica);
hold on;
for t=1:lt
ezplot(@(x,y,t) linefunca(x,y,t),[1,lt]);
end
回答1:
As far as I know, ezplot
can not plot a series of lines like plot
. A way to work around this would be to add a parameter k
to the anonymous function, which is used to select the current line. You can then go through all lines in a for loop and plot them one-by-one.
Further: as it is stated on the ezplot help page, you have to use the array functions .*
, ./
and .^
, so ezplot
can use vectors to evaluate the function.
N = 5;
aa = rand(N,1); ba = rand(N,1); ca = rand(N,1);
linefunca = @(xa,ya,k) aa(k).*xa + ba(k).*ya + ca(k);
hold on
for k=1:N
ezplot(@(x,y)linefunca(x,y,k),[-5,5,-5,5]);
end
hold off
来源:https://stackoverflow.com/questions/28825057/ezplot-in-matlab-how-to-plot-using-a-function-handle