how can i write this lissajous function in matlab????

hi all
I knew that my question is so silly, but I am new I matlab area and I need help:
I have this lissajous function:
x (t)=Asin(at+d)
y (t)=Bsin(bt)
where t = from 0 to 2pi, what I need is to know how I can write this function in an m-file which take three scalars a, b, and d , and a vector t as its arguments and returns two vectors x(t) and y (t) also A=B=1
thanks for any one help
mari
regards

 Respuesta aceptada

Andrei Bobrov
Andrei Bobrov el 8 de Ag. de 2012
Editada: Andrei Bobrov el 8 de Ag. de 2012
your_lissajous = @(t,a,b,d)[sin(a*t(:)+d), sin(b*t(:))];
eg of use function your_lissajous
xy = your_lissajous(0:pi/100:2*pi,7,8,0);
plot(xy(:,1),xy(:,2))

2 comentarios

mari gaji
mari gaji el 9 de Ag. de 2012
hi Andrei and thanks: but there is an error in this cod (??? Undefined function or method 'your_lissajous' for input arguments of type 'double'.) this is what result in matlab
With the (valid) definition that Andrei gave, you would only be able to invoke "your_lissajous" from within a function that had the assignment statement given. If you need to define it for use in all routines, you will need to store the following in your_lissajous.m
function xy = your_lissajous(t, a, b, d)
xy = [sin(a*t(:)+d), sin(b*t(:))];
end

Iniciar sesión para comentar.

Más respuestas (1)

The function heading would be
function [x, y] = my_lissajous(a, b, d, t)

2 comentarios

mari gaji
mari gaji el 8 de Ag. de 2012
thank alot Walter but there is another question please, when i writ downe the cod and try to run it there was an error which indicate that the value of A is undefinde eventhough i had writ it?????
Remember that MATLAB is case sensitive, so "A" is not the same as "a". It does not matter which of the two you use, but you must be consistent.

Iniciar sesión para comentar.

Categorías

Más información sobre Configure Simulation Conditions en Centro de ayuda y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by