How to plot this function with 2 variables?

9 visualizaciones (últimos 30 días)
Marisa
Marisa el 30 de Oct. de 2023
Movida: Dyuman Joshi el 30 de Oct. de 2023
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 comentarios
Marisa
Marisa el 30 de Oct. de 2023
Dyuman Joshi
Dyuman Joshi el 30 de Oct. de 2023
Movida: Dyuman Joshi el 30 de Oct. de 2023
As you are using fplot, the expected input is a function handle.
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 -

Iniciar sesión para comentar.

Respuestas (1)

Voss
Voss el 30 de Oct. de 2023
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 comentarios
Sam Chak
Sam Chak el 30 de Oct. de 2023
Good to hear that, @Marisa. 👍
Sam Chak
Sam Chak el 30 de Oct. de 2023
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.

Iniciar sesión para comentar.

Categorías

Más información sobre Mathematics en Help Center y File Exchange.

Productos


Versión

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by