How can I generate a sine signal where I can manipulate the input parameters such as its amplitude, frequency, start time and phase?
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
dpb
2015-3-11
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.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Waveform Generation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!