MATLAB Answers

0

How to calculate integral of a square waveform

Ashwini Amin さんによって質問されました 2018 年 8 月 10 日
最新アクティビティ Ashwini Amin さんによって コメントされました 2018 年 8 月 24 日
Hi,
Could you please let us know how to calculate integral of a square waveform using Matlab

  0 件のコメント

サインイン to comment.

1 件の回答

Ameer Hamza
回答者: Ameer Hamza
2018 年 8 月 10 日

You can use the square() function to create a square wave with the time period of 2*pi and amplitude between -1 and 1. And then use trapz() to evaluate the integral numerically. For example
t = 0:0.1:10; %%choose the range you want
y = square(t);
trapz(t,y)

  2 件のコメント

Ashwini Amin 2018 年 8 月 24 日
Hi,
Thank you for your response. I am trying below but i am unable to use this function as it is displaying me a error. Please help
t=0:1e-3:4; S1t=heaviside(t)-heaviside(t-2); S2t=heaviside(t)-2*heaviside(t-1)+heaviside(t-2); S3t=heaviside(t)-2*heaviside(t-2)+heaviside(t-3); S4t=-1*heaviside(t)+heaviside(t-3);
subplot(411);
plot(t,S1t);
title(' S1 ');
subplot(412);
plot(t,S2t);
title(' S2 ');
subplot(413);
plot(t,S3t);
title(' S3 ');
subplot(414);
plot(t,S4t);
title(' S4 ');
%Energy of the signal1
e1Energy= sum(abs(S1t).^2)*1e-3 e2Energy= sum(abs(S2t).^2)*1e-3 e3Energy= sum(abs(S3t).^2)*1e-3 e4Energy= sum(abs(S4t).^2)*1e-3 figure(2); squareRoote1 = sqrt(e1Energy); %F1(t) solution f1t = S1t/squareRoote1; figure(2); subplot(411); plot(t,f1t);
%Calculate C12
%c12input = S2t*f1t;
c12 = trapz(t,S2t,f1t)
Error : Error using trapz Dimension argument must be a positive integer scalar within indexing range.
Ashwini Amin 2018 年 8 月 24 日
I am trying to calculate the integration of 2 signals. Please suggest a better option to calculate this from -inf to +inf limits

サインイン to comment.



Translated by