# Confusion in linearity? I am studying linear systems from the book "Signals and Systems Laboratory with MATLAB". I have performed an example on MATLAB myself in this regard. Code is as follow:

clc
clear all
close all
t=-3:.1:3;
x1=sin(t);
x2=cos(t);
a1=2;
a2=3;
z=a1*x1+a2*x2;
y1=2*z+2*cos(pi*t/3)
plot(t,y1);
ylim([-1 11]);
figure;
z1=2*x1+2*cos(pi*t/3);
z2=2*x2+2*cos(pi*t/3)
y2=a1*z1+a2*z2;
plot(t,y2);
ylim([-1 19]);


When I run this program I get two figures containing two same shapes that are curve-like but amplitude/size/height is not same.

I am confused if my this system defined by equation y=2*z*cos(pi*t/3) used in program above is linear or not? If still yes, then why (as we have size difference in both curves)?

• I tried to improve the typesetting, but did not understand the last y= equation, and the actual question. Could you provide more details? – Laurent Duval Apr 11 '19 at 18:15
• dear@LaurentDuval . I for got to set both outputs with different names/identifier. I have now edited my code for clarification. So now y1 represents left hand side of linearity equation and y2 represents right hand side of linearity equation. As per requirement/law of linearity both sides of equation should be equal – engr Apr 12 '19 at 5:10
• i have highlighted linearity equation in attached photo – engr Apr 12 '19 at 5:40