So i have a function that inputs coordinates and plots a line
function linetranslation(xa,ya,xb,yb)if nargin == 0 xa = input('First X Coordinate : '); ya = input('First Y Coordinate : '); xb = input('Second X Coordinate : '); yb = input('Second Y Coordinate : '); endclf;hold on;axis([-10 10 -10 10]);if xa==xb if ya<yb for yi=ya:0.01:yb; xi=yi+xa-yi; plot(xi,yi); end else for yi=ya:-0.01:yb; xi=yi+xa-yi; plot(xi,yi); end endelse m=(yb-ya)/(xb-xa); if xa<xb for xi=xa:0.01:xb; yi=m*(xi-xa)+ya; plot(xi,yi); end else for xi=xa:-0.01:xb; yi=m*(xi-xa)+ya; plot(xi,yi); end endendend
the question is how can i pass xi & yi to another function that processes it further
a little idea here, i have tried adding to the first function
function [xi, yi] = linetranslation(xa,ya,xb,yb)
and adding the code below
function Translate(x,y)>>>here [xi , yi] = linetranslation(xa,ya,xb,yb);if nargin == 0 % Check the number of input arguments (nargin)
x = input('Translate X: '); y = input('Translate Y: '); end hold on; axescenter axis([-10 10 -10 10]); plot(xi+x,yi+y);
but it returns xa undefined, on the other hand i need xi and yi to be passed
thanks in advance
UPDATE
i have tried putting
[xi,yi] = translasigaris;
below
function translate(x,y)
but
if nargin == 0 xa = input('First X Coordinate : '); ya = input('First Y Coordinate : '); xb = input('Second X Coordinate : '); yb = input('Second Y Coordinate : '); end
returns as an infinite loop.
Best Answer