how can i plot including sym data in graph?

조회 수: 4 (최근 30일)
규호
규호 2023년 2월 22일
댓글: Star Strider 2023년 2월 26일
i need help
i want to plot this equation in ficture
so , i make code
%%%%
fs=3000;
t= 0 : 1/fs : 10;
m_amplitude=1;
sensitivity=1;
fm=3;
fc=10;
frequency_deviation=m_amplitude*sensitivity;
modulation_index=frequency_deviation/fm
message=square(2*pi*fm*t);
syms t
F=int(message, [0 t]);
y=cos(2*pi*fc+modulation_index*F);
plot(t,y)
but it doesn't work
how can i plot including sym data in graph?
  댓글 수: 1
Askic V
Askic V 2023년 2월 22일
Please look at the documentation:
https://www.mathworks.com/help/symbolic/fplot.html

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

채택된 답변

Star Strider
Star Strider 2023년 2월 22일
Thia approach works —
fs=3000;
t= 0 : 1/fs : 10;
t = 0: 1/fs : 2.5; % Substitute To Allow Evaluation Within 55 Seconds
m_amplitude=1;
sensitivity=1;
fm=3;
fc=10;
frequency_deviation=m_amplitude*sensitivity;
modulation_index=frequency_deviation/fm;
message = @(t) square(2*pi*fm*t);
% syms t
F= arrayfun(@(t)integral(message, 0, t), t);
Warning: Minimum step size reached near x = 2. There may be a singularity, or the tolerances may be too tight for this problem.
Warning: Minimum step size reached near x = 2. There may be a singularity, or the tolerances may be too tight for this problem.
y=cos(2*pi*fc+modulation_index*F);
plot(t,y)
However it takes too long to evaluate here, so I created a shortened version of the ‘t’ vector so it could be evaluated in the required 55 seconds. See the documentation on arrayfun for details.
An alternative (that I did not experiment with) could be to evaluate ‘message’ and use the cumtrapz function.
.
  댓글 수: 2
규호
규호 2023년 2월 26일
thank you
Star Strider
Star Strider 2023년 2월 26일
As always, my pleasure!

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

추가 답변 (0개)

카테고리

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