How to plot a function of multiple variables, where only 1 variable is unknown

조회 수: 9 (최근 30일)
GRANT
GRANT 2023년 9월 7일
답변: Pooja Kumari 2023년 9월 7일
Hello,
I am trying to look into hilbert transforms for my class. I am fairly new to matlab so I am experiencing some trouble trying to plot these functions.
Below is some code for a raisedCosine sqrt funciton (IIR) and I am trying to plot this as a function of t with specified values of tau, T_b, and alpha. When I run this code I get the picture below, which is essentially nothing. Am I coding this correctly? I was not able to find alot of support on this exact question.
  댓글 수: 3
GRANT
GRANT 2023년 9월 7일
syms t
fplot(raisedCosineSqrt(t, 0.3e-6, 1e-6, 0.25), [-100 100])
ylim([-10 10])
syms test
test = raisedCosineSqrt(t, 0.3e-6, 1e-6, 0.25)
syms f omega convolution
f = raisedCosineSqrt(t, 0.3e-6, 1e-6, 0.25) * raisedCosineSqrt(t-omega, 0.3e-6, 1e-6, 0.25);
f
convolution = int(f, -inf, inf);
function rc_sq_t = raisedCosineSqrt(t, tau, T_b, alpha)
rc_sq_t = (1/sqrt(T_b))*((sin((1-alpha)*(pi*t/T_b))+(4*alpha*t/T_b)*(cos((1+alpha)*pi*t/T_b)))/((pi*t/T_b)*(1-(4*alpha*t/T_b)^2)));
end
GRANT
GRANT 2023년 9월 7일
Added some extra to it for testing purposes. Trying to debug this right now.

댓글을 달려면 로그인하십시오.

답변 (1개)

Pooja Kumari
Pooja Kumari 2023년 9월 7일
Dear GRANT,
I understand that you are facing issues when plotting the raisedCosine square root function (IIR) as a function of 't', using specified values of 'tau', 'T_b', and 'alpha'. Instead of creating a separate function to obtain the output of the raisedCosine square root function, you can directly store the output in a variable called 'rc_sq_t'. I have provided a sample code below for reference:
% Define the symbolic variable
syms t
tau =0.3e-6;
T_b = 1e-6;
alpha = 0.25;
% Define the function
rc_sq_t = (1/sqrt(T_b))*((sin((1-alpha)*(pi*t/T_b))+(4*alpha*t/T_b)*(cos((1+alpha)*pi*t/T_b)))/((pi*t/T_b)*(1-(4*alpha*t/T_b)^2)));
% Plot the function
fplot(rc_sq_t,[-100,100])
You can refer to the below documentation for more information on "fplot" function:
I hope this helps!

카테고리

Help CenterFile Exchange에서 Calculus에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by