Generate waveform using basic matlab code

조회 수: 3(최근 30일)
I want to create the attached waveform using simple basic matlab code. Can someone please help me through the process on how to generate such waveforms through matlab coding not using any matlab defined function. Appreciate all the help.

채택된 답변

Sam Chak
Sam Chak 2022년 7월 28일
The given waveform is a piecewise smooth function, and it can be constructed as follows:
t = 0:0.1:2000;
% Defining the Segments
x1 = 0.07*(t < 200); % segment 1
x2 = ((0.37 - 0.07)/( 600 - 200)*t - 0.08).*(( 200 <= t) & (t < 600)); % segment 2
x3 = 0.37*((600 <= t) & (t < 800)); % segment 3
x4 = ((0.70 - 0.37)/(1200 - 800)*t - 0.29).*(( 800 <= t) & (t < 1200)); % segment 4
x5 = 0.70*((1200 <= t) & (t < 1800)); % segment 5
x6 = ((0.00 - 0.70)/(2000 - 1800)*t + 7.00).*((1800 <= t) & (t < 2000)); % segment 6
% Combining all segments and plotting it
x = x1 + x2 + x3 + x4 + x5 + x6;
plot(t, x, 'linewidth', 1.5)
ylim([0 1]), grid on, xlabel('t'), ylabel('x(t)'), title('Piecewise Smooth Function')
  댓글 수: 1
Abhibrata Adhikary
Abhibrata Adhikary 2022년 8월 1일
Thank you @Sam Chak. This is very helpful.

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

추가 답변(0개)

태그

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by