create user buttons to change frequency while simulation is running

1 view (last 30 days)
sumeet on 9 Apr 2014
Hi, My aim is to illustrate lissajous figure of CRO. The concept is to plot a locus of point whose x & y coordinate vary with time. In the code given below I have put x=sin(constant x t) , y=cos(1.5 x constant x t)
if true
Fs = 8000; % samples per second
dt = 1/Fs; % seconds per sample
StopTime = 6.00; % seconds
t = (0:dt:StopTime-dt)'; % seconds
%%Sine wave:
Fc = 80; % hertz
c = -pi:.04:pi;
cx = sin(pi*Fc*t);
cy = cos(1.5*pi*Fc*t);
axis on, axis equal
line(cx, cy, 'color', [.4 .4 .8],'LineWidth',3);
title('sine on x , sine on y ','Color',[.6 0 0])
hold on
while (1)
for t = 1:length(t)
x(2) = cx(t);
y(2) = cy(t);
t = (0:dt:StopTime-dt)';
ignore 'if true' and 'end' (i wanted my code to appear properly for viewers)
I have 3 questions (1)If you will run this , you will see (other than a nice double boomerang animation) a red dot at origin in graph which I want to avoid. (2)I want to create a slider button for user which replaces 1.5 in above . This way , when slider=1 you will see circle , as frequency multiplies you will see more vertically side by side loops . As frequency diminishes to fraction loop will appear horizontally stacked. (3)Here phase difference is 90 degree . If I gave user freedom to change it via slider dynamically , it will get exciting as the figure will flatten or swell .
Thank You . Eagerly waiting for your valuable suggestions .

Answers (0)


Community Treasure Hunt

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

Start Hunting!

Translated by