How to plot this function with 2 variables?
古いコメントを表示
Hello, I’m having a hard time plotting z2(t). I keep getting the error “input must be a function or functions of a single variable”. I’m not sure how to properly define “u”.
2 件のコメント
Marisa
2023 年 10 月 30 日
Dyuman Joshi
2023 年 10 月 30 日
移動済み: Dyuman Joshi
2023 年 10 月 30 日
And the syntax to define a function handle is
name_of_handle = @(independent_variables) relation_or_expression_of_independent_variables
%For the first example, it translates to
z1 = @(t) exp(t);
Refer to these links for more information -
回答 (1 件)
t = -2:0.01:2;
z1 = exp(t);
z2 = 2*(t+1 >= 0);
z3 = 0.5*sin(7*t);
hold on
grid on
plot(t,z1,'-','LineWidth',2)
plot(t,z2,':','LineWidth',2)
plot(t,z3,'--','LineWidth',2)
xlabel('t')
ylabel('z')
legend("z"+[1 2 3])
ylim([-1 8])
9 件のコメント
Dyuman Joshi
2023 年 10 月 30 日
Just a note -
z2 = 2*(t+1 >= 0);
">= 0" is not mentioned in the question
Voss
2023 年 10 月 30 日
I interpret u(t) to be the unit step function.
Dyuman Joshi
2023 年 10 月 30 日
Alright.
Marisa
2023 年 10 月 30 日
The signal u(·) in the question most likely refers to the unit step function, which can be represented by the Heaviside function.
t = -2:0.001:2;
z2 = 2*heaviside(t + 1);
plot(t,z2,':','LineWidth',2), grid on
xlabel('t')
ylabel('z')
ylim([-1 8])
Marisa
2023 年 10 月 30 日
Sam Chak
2023 年 10 月 30 日
Hi @Marisa
In the mathematical representation of linear physical systems (later in your course), you may encounter the state-space equation,
. But this
is not the unit step function. Please keep that in mind.
カテゴリ
ヘルプ センター および File Exchange で Mathematics についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


