Summing result of multiple function calls to verify Nyquist criterium

1 次查看(过去 30 天)
I am writing code to plot a certain signal, P(f) with shifts of 1/T. Now I am interested in a method to add all these separate and limited functions [-1/T 1/T] and plot them in the same fplot window to verify if the result satisfies the Nyquist criterium for zero inter symbol interference .
T = 1;
bounds = [-1/T 1/T];
P = @(f) 1./sqrt(T) .* cos(pi.*f.*T./2);
NO_graphs = 3;
for m = -(NO_graphs-1)/2:1:(NO_graphs-1)/2
bounds = [-1/T+m/T 1/T+m/T];
p_next = FuncShift(p, 1/T*m);
fplot(p_next,bounds);
hold on
end
function [ func_up ] = FuncShift( func, shift ) %not mine but works like a charm
func_up = @(x)(func(x-shift));
end

回答(1 个)

Sai Sumanth Korthiwada
The given code plots the functions from [-1/T 1/T] in the same window. Changing the case of the variable from “P” to “p” in line 4 will output the desired “fplot” in a single window using “hold on” keyword.
T = 1;
bounds = [-1/T 1/T];
% replacing 'P' with 'p'
p = @(f) 1./sqrt(T) .* cos(pi.*f.*T./2);
NO_graphs = 3;
for m = -(NO_graphs-1)/2:1:(NO_graphs-1)/2
bounds = [-1/T+m/T 1/T+m/T];
p_next = FuncShift(p, 1/T*m);
fplot(p_next,bounds);
hold on
end
function [ func_up ] = FuncShift( func, shift ) %not mine but works like a charm
func_up = @(x)(func(x-shift));
end
Please refer to fplot MathWorks documentation for more information related to Plot expression or function.

类别

Help CenterFile Exchange 中查找有关 Calculus 的更多信息

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by