xlab = '$x$';
ylab = {'$h_0(x)$','$g(x)$'};
colors = {[0 0 0;0 0 0;0 0 0],[1 0 0]};
lt = {{'-',':','--'},{'-'}};
fn = 'times'; fs = 20;
lw = 3;
legendlabels= {{'1','2','3'},{''}};
dat=createData();
x=-25:0.2:25; x=x';
g = sin(2*pi*x/50);
dat=addvars(dat,g);
s=plotStack(dat,lw,fs,fn,colors,lt,xlab,ylab,legendlabels);
function dat=createData()
x=-25:0.2:25; x=x';
dat = table();
dat = addvars(dat,x);
datarow = zeros(length(x),3);
for i=1:3
datarow(:,i) = cos(2*pi*i*x/50);
end
dat =addvars(dat, datarow,'NewVariableNames',{'data'});
end
function [s]=plotStack(dat,lw,fs,fn,colors,linetypes,xlabel,ylabels,legendlabels)
s=stackedplot(dat,'XVariable','x','Linewidth',lw,'Fontname',fn,'Fontsize',fs);
s.XLabel = xlabel;
s.DisplayLabels=ylabels;
lp = s.LineProperties;
for i=1:length(lp)
lp(i).Color=colors{i};
lp(i).LineStyle=linetypes{i};
end
ax = s.AxesProperties;
for i=1:length(ax)
ax(i).LegendLabels=legendlabels{i};
end
end
0 Comments
Sign in to comment.