Help with creating a function that contains subplot and then calling the function so that u get a single figure of those subplots.
1 view (last 30 days)
Show older comments
%% Testing additivity and scaling property of y(t) = 2x(t). In another script when i type " plotlti( 2 * x) " it gives me only one plot.
%% Need help to get 2 plots in one figure.
%plotlti.m : function [ ] = plotlti (T)
%% Additivity Property clf
t1 = -5:0.05:5;
t2 = -5:0.5:5;
% Exp #1:
x1 = u(t1);
x2 = u(t1);
x = plus(x1,x2);
e1a = eval(T);
xlim([-5 5]);
hold on;
% Exp #2:
x = u(t2);
y1 = eval(T);
y2 = y1;
e2a = plus(y1,y2);
hold on;
%%Scaling Property
% Exp #1:
y = u(t1);
e1s = 2 * eval(T);
xlim([-5 5]);
hold on;
% Exp #2:
y = 2 * u(t2);
e2s = eval(T);
hold on;
subplot( 2, 1 ,1);
title( 'Additivity Property');
plot(t1,e1a,'LineWidth', 1.5);
hold on;
plot(t2,e2a, 'or', 'MarkerFaceColor', 'r')
legend ( { 'Experiment#1' , 'Experiment#2'});
ylim([-1,5]);
grid on;
hold off;
subplot( 2, 1 ,2);
title( 'Scaling Property');
plot(t1,e1s,'LineWidth', 1.5);
hold on;
plot(t2, e2s, 'or', 'MarkerFaceColor', 'r')
legend ( { 'Experiment#1' , 'Experiment#2'});
ylim([-1,5]);
grid on;
hold off;
return end
1 Comment
Answers (0)
See Also
Categories
Find more on Title in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!