I want to plot x(t) = cos(200*pi*t*u(t)) and define u(t) seprately and then plot x(-t),x(t/3)
i wrote this
x = @(t) cos(200*pi*t*u(t));
t = linspace(-1, 1);
figure(1)
plot(t, x(t))
grid
function y = u(x)
y=0;
if x>=0
y=1;
end
end

 採用された回答

Star Strider
Star Strider 2019 年 10 月 19 日

0 投票

This should get you started:
u = @(t) t>=0;
x = @(t,u) cos(200*pi*t.*u(t));
t = linspace(-1, 1);
figure(1)
plot(t, x(t,u))
grid
Extending that:
u = @(t) t>=0;
x = @(t,u) cos(200*pi*t.*u(t));
t = linspace(-1, 1);
figure(1)
plot(t, x(t,u))
hold on
plot(t, x(-t,u))
plot(t, x(t/3,u))
hold off
grid
Experiment to get different results.

8 件のコメント

Mohammadreza kalantari
Mohammadreza kalantari 2019 年 10 月 19 日
thanks a lot
whats about 1/x(t,u) & x(1/t,u)
I think the eror is devided by zero
how can i solve it?
Star Strider
Star Strider 2019 年 10 月 19 日
My pleasure.
Add: 1E-14 (or some similar small value) to whatever is in the denominator. That will still result in a very large number, however not Inf or NaN.
Note that in those instances, you need to use element-wise division, ./. See the documentation section on Array vs. Matrix Operations for a fulll discussion.
Mohammadreza kalantari
Mohammadreza kalantari 2019 年 10 月 26 日
ok
now i want to plot A*exp(j*2*pi*t)
which A is a constant variable and j is an imaginary unit
Star Strider
Star Strider 2019 年 10 月 26 日
Try this:
A = 42; % Universal Answer (HHGTTG)
y = @(t) A*exp(1j*2*pi*t)
t = linspace(-1, 1);
figure
plot(t, real(y(t)),'-b', t, imag(y(t)), '--')
grid
legend('\Re', '\Im')
Experiment to get the result you want.
Mohammadreza kalantari
Mohammadreza kalantari 2019 年 10 月 31 日
編集済み: Mohammadreza kalantari 2019 年 10 月 31 日
Thanks.
i want to stem y[n]=y[n-2]+x[n]+2x[n-1] which is recursive and y[0]=1,y[-1]=5, x[n]=(1.5.^n).*u[n]
delta = @(d) d==0;
and also stem conv(y,delta)
can you help me?
Star Strider
Star Strider 2019 年 10 月 31 日
This should be posted as a new Question.
Mohammadreza kalantari
Mohammadreza kalantari 2019 年 10 月 31 日
編集済み: Mohammadreza kalantari 2019 年 10 月 31 日
I asked in that way too.
Star Strider
Star Strider 2019 年 10 月 31 日
I will delete this Comment in a few minutes, then.

サインインしてコメントする。

その他の回答 (1 件)

Asif
Asif 2024 年 4 月 4 日

0 投票

t=0:0.01:5; %Time from 0 to 5 seconds with a step size of 0.01 seconds
%Define the continous signal ( for example, a sinusoidal signal)
% Frequency=2; %Frequency of the sinusoid in HZ
Amplitude=1; % Amplitude of the sinusoid
Phase = pi/4; %phase of the sinusoid ( in radians)
signal = Amplitude*sin(2*pi*Frequency*t+Phase);
% plot the continuous signal
plot(t, signal,'b','Linewidth',6);
xlabel('xTime(s)X');
ylabel('Ampltitude');
title('Continuous Sinusoidal signal');
grid on

カテゴリ

ヘルプ センター および File ExchangeMatrices and Arrays についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by