How can I generate a sine signal where I can manipulate the input parameters such as its amplitude, frequency, start time and phase?

1 view (last 30 days)
This is my layout. I used edit text to enter the value. In plot callback I used the following coding to get the input and generate the signal when the plot push button is clicked.
a1 = str2num(get(handles.edit_amplitude,'String')); % get input for Textbox1
a2 = str2num(get(handles.edit_frequency,'String')); % get input for Textbox2
a3 = str2num(get(handles.edit_phase,'String')); % get input for Textbox3
a4 = str2num(get(handles.edit_time1,'String')); % get input for Textbox4
a5 = str2num(get(handles.edit_time2,'String')); % get input for Textbox5
From here what coding should I do to generate the sine signal?
  3 Comments
Nur Fauzira Saidin
Nur Fauzira Saidin on 11 Mar 2015
Edited: Nur Fauzira Saidin on 11 Mar 2015
Thank you so much for your suggestion. I've made a changes in my coding and I added a new parameter: vertical shift.
But I'm so sorry I don't quite understand your question and hint. If you don't mind can you elaborate more? And the last three lines of my coding are to generate the sine signal, but nothing is happening when I clicked the push button. Can you tell me which part is wrong?
dpb
dpb on 11 Mar 2015
OK, looks like you did pick up on the omega=2pi*f portion; that looks ok. Now for the time vector, have you heard about the Nyquist sampling frequency?
Try just at the command line a short series; you'll see that to generate a representative sine you have to sample at more than just the frequency of the fundamental frequency or you only get a hit-n-miss representation; in fact if the sample frequency is at the same frequency as the sine then you only get a single value--one at each period but the same location in relative phase so you get what?--a straight line on a plot.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!