MATLAB: Could you help me with FUNCTION syntax

coordinate systemfunction

Hi, could you help me please, how to make a function – for example
function [xx,yy,xx1,yy1,a,aa,b,bb]=(x,y,x1,y1)
(this is I tryed and it doesnt work 🙁 )
I have a points in my code (predefined – x,y,x1,y1) and I want change this points for a function (its mean write my own coordinate of points to the command window). Then I Interpolate and approximate this points by spline and polyfit.
Here is my code syntax (it works good, but I wanna make this like a function).. Thanks for any help, I just learning in Matlab so use simply answer 🙂
CODE:
obr = imread('Pokus1.jpg');
obr = obr(:,:,1);
obr = im2double(obr);
figure(1)
imshow(obr,[]);
[a,b]=size(obr);
x=[19.25 ; 217.25 ; 523.25 ; 806.75 ; 1135.25 ; 1345.25 ; 1612.25];
y=[545.75 ; 364.25 ; 155.75 ; 92.75 ; 145.25 ; 256.25 ; 418.25];
x1=[163.25 ; 361.25 ; 778.25 ; 1007.75 ; 1175.75 ; 1409.75];
y1=[572.75 ; 358.25 ; 178.25 ; 200.75 ; 265.25 ; 425.75];
hold on
axis on
plot (x,y,'o');
xx = 1:0.01:b;
yy = spline(x,y,xx);
hold on
plot(x,y,'o',xx,yy, 'LineWidth', 3);
plot (x1,y1,'o');
xx1 = 1:0.01:b;
yy1 = spline (x1,y1,xx1);
hold on
plot(x1,y1,'o',xx1,yy1, 'LineWidth', 3);
hold off
figure(2)
imshow(obr,[]);
p = polyfit(x,y,2);
a = 1:0.01:b;
aa = polyval (p,a);
hold on
axis on
plot(x,y,'o',a,aa, 'LineWidth', 3);
p1 = polyfit(x1,y1,2);
b = 1:0.01:b;
bb = polyval (p1,b);
plot(x1,y1,'o',b,bb, 'LineWidth', 3);
hold off

Best Answer

The line
function [xx,yy,xx1,yy1,a,aa,b,bb]=(x,y,x1,y1)
needs to have the function name added between the "=" and the "("