68 views (last 30 days)

Show older comments

syms t

x(t) = piecewise (t>=0, sin(3*t), t>=2*pi, sin(3*t)^2, t>3*pi,0);

t1 =0:0.1:3*pi;

x=subs(x,t,t1);

plot(t1,x)

xlabel('Time')

ylabel('x(t)')

disp('Energy of x(t)')

Energy of x(t)

I1 = int(sin(3*t)^2);

I2 = int(sin(3*t)^4);

E = I1(2*pi)-I1(0)+I2(2*pi)-I2(3*pi)

Energy of x(t)

Unrecognized function or variable 'Energy'.

This is my code I'm not sure why it is saying unrecognized function any help would be appreciated thank you.

Steven Lord
on 8 Feb 2021

madhan ravi
on 8 Feb 2021

Following Steven’s answer would clear that error but you will have a following error, so change that part of your code to the following:

%Energy of x(t)

I1(t) = int(sin(3*t)^2);

I2(t) = int(sin(3*t)^4);

E = I1(2*pi)-I1(0)+I2(2*pi)-I2(3*pi)

%Energy of x(t)

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

Start Hunting!