필터 지우기
필터 지우기

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

조회 수: 2 (최근 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
Nur Fauzira Saidin
Nur Fauzira Saidin 2015년 3월 11일
편집: Nur Fauzira Saidin 2015년 3월 11일
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 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 CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by