Hello,
I have a square wave but this wave is not an ideal square wave. What I mean is, for example from the first sample of positive peak to the last sample of the positive peak, I have 100 datas. In the next positive peak, I have 91 datas. I want to plot a sine wave which changes adaptively by the number of samples in the positive and negative peaks. This sine wave's positive period should end when the square waves positive peak drops to the zero. Or the best continuous wave that fits with this square wave. Thanks for your advices.

댓글 수: 3

Walter Roberson
Walter Roberson 2022년 9월 28일
You can certainly splice together cycles, but I am wondering if that is good enough, or if you need more continuity? And I wonder if you need a pure sine for each cycle? For example if you built a sine function with increasing frequency over time then it might be continuous but it would be an increasingly compressed wave (frequency modulation)
tinkyminky93
tinkyminky93 2022년 9월 28일
No i do not need a pure sine wave, enough is enough. It can be like linear interpolation.
Image Analyst
Image Analyst 2022년 9월 28일
"I have a square wave" <== but you forgot to attach it. Please attach it as a .mat or .txt file with the paperclip icon.

댓글을 달려면 로그인하십시오.

 채택된 답변

Chunru
Chunru 2022년 9월 28일

0 개 추천

% generate a square wave with no fixed period
f = 0.125; fs=1;
s = 0.3+sin(2*pi*f*(0:40)); % a sine wave with offset
x =2* (s>0) -1; % square wave
stem(x);
y = lowpass(x, f*1.5, fs);
hold on
plot(y)

댓글 수: 3

tinkyminky93
tinkyminky93 2022년 9월 29일
편집: tinkyminky93 2022년 9월 29일
Why you add offset sır? And is it possible to add zeros to sine wave? When the period ends, i have 5 sample of zeros
Walter Roberson
Walter Roberson 2022년 9월 29일
The offset biases there to be more positive values than negative values.
However the end result has fixed frequency, f: the 0:40 are acting as time.
tinkyminky93
tinkyminky93 2022년 9월 29일
Simply low pass filtering my square wave gives me a sine wave. Seems like I do not need a solution like that.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

제품

릴리스

R2021b

질문:

2022년 9월 28일

댓글:

2022년 9월 29일

Community Treasure Hunt

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

Start Hunting!

Translated by