How can i plot this: x(t) = |t| * rect((t - 1)/3)

4 ビュー (過去 30 日間)
Elisa
Elisa 2022 年 12 月 12 日
コメント済み: Jon 2022 年 12 月 12 日
I am trying to plot this function x(t) = |t| * rect((t - 1)/3)
than i need to transform it with fft (fouriertransform)
could someone help me?

回答 (1 件)

Jon
Jon 2022 年 12 月 12 日
編集済み: Jon 2022 年 12 月 12 日
As far as I know, rect is not a MATLAB function. Perhaps it is one you defined and saved in an m file. Assuming this is the case this is the typical pattern for plotting some function.
% define the dependent variable, in this case t over the range of interest
t = linspace(0,10); % for example from 0 to 10, you can put in the range you wante
% evaluate the function, assume function is vectorized so it can accept a
% vector input
x(t) = |t| * rect((t - 1)/3);
% plot the function
plot(t,x)
title('my function')
xlabel('time [s]'); % put in what you want for x axis label
ylabel('my functions value'); %put in what you want for the y axis label
regarding performing fft refer to the documentation
type doc fft on the command line
  2 件のコメント
Les Beckham
Les Beckham 2022 年 12 月 12 日
use abs(t) instead of |t|
Jon
Jon 2022 年 12 月 12 日
Good catch, thanks - I had just done a copy and paste of the OP's function just to illustrate how to generate a plot and hadn't noticed that

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

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by