When posting a question including codes, use the proper code format to properly shape your question.
At multiple instances you defined equations similar to:
while it should be:
There was a whole bunch of other typos too. Also, you did not accurately define the limits of 'x' for pretty much all the segments of the waves. Some times if you pay attenuation to the details of the errors MATLAB provides, you can debug your code a lot faster than asking on MATLABAnswers! Any who, here is the correct version of the code you are looking for. Hope it helps!
clc; clear all;
imx=8;
imn=2;
T = 20;
s1= @(x) (imx+imn).*((0<=x & x<T/6) | (x>=5*T/6 & x<=T)) ...
+(imx+imn*(2-6*x/T)).*(T/6<=x & x<T/3)...
+(imx).*(T/3<=x & x<2*T/3)...
+(imx+imn*(6*x/T-4)).*(2*T/3<=x & x<5*T/6);
x = linspace(0, 20,500);
I1 = s1(x);
figure(1)
plot(x,I1)
ylim([.9*imx 1.1*(imx+imn)])
clc; clear all;
imx=8;
imn=2;
T = 20;
s2= @(x) (imx+imn*(6*x/T)).*(0<=x & x<T/6) ...
+(imx+imn).*(T/6<=x & x<T/2)...
+(imx+imn*(4-6*x/T)).*(T/2<=x & x<2*T/3)...
+(imx).*(2*T/3<=x & x<=T);
x = linspace(0,20,500);
I2 = s2(x);
figure(2)
plot(x,I2)
ylim([.9*imx 1.1*(imx+imn)])
THIRD TRAPEZOIDAL WAVE FORM
clc;
clear all;
imx=8;
imn=2;
T = 20;
s3= @(x) (imx).*(0<=x & x<T/3) ...
+(imx+imn*(6*x/T-2)).*(T/3<=x & x<T/2)...
+(imx+imn).*(T/2<=x & x<5*T/6)...
+(imx+imn*(6-6*x/T)).*(5*T/6<=x & x<=T);
x = linspace(0,20,500);
I3 = s3(x);
figure(3)
plot(x,I3)
ylim([.9*imx 1.1*(imx+imn)])
Best Answer