# Plotting Output of Function Given Transfer Function and Input in MATLAB

• magnifik
In summary, the conversation discusses the process of plotting the output of a function in MATLAB, given a transfer function and an input. The transfer function is defined as H(s) = 1000/(s^2 + s + 1000) and the input is given as 1 from 0 < t < 10 and 0 elsewhere. The speaker is trying to express the input as a function in MATLAB, specifically x(t) = U(t)*U(10 - t). They plan to use the ilaplace function and convolution to obtain the output. The conversation also mentions the use of the heaviside function and the need for specifying a time interval.
magnifik
i am trying to plot the output of a function given the transfer function and an input. however, i am having trouble with trying to express the input as a function in MATLAB

my transfer function is
m = 1;
b = 2;
k = 1000;
num = [ 1000 ];
den = [ m b k ];
transferfunction = tf(num, den)

so it's equal to H(s) = 1000/(s^2 + s + 1000)

i am given that the input is 1 from 0 < t < 10 and 0 elsewhere
i know that x(t) in terms if unit step is x(t) = U(t)*U(10 - t) --- how do i express this in MATLAB?

after this, my plan is to do q = ilaplace(transferfunction) and conv(q, x) to get the output. is this a correct method?

is this correct...
t = 0:0.001:10; %do i even need this??
td = 10;
x1 = heaviside(t) - heaviside(t-td);

## 1. How do I plot the output of a function in MATLAB using a given transfer function and input?

To plot the output of a function using a transfer function and input in MATLAB, you can use the lsim function. This function takes in the transfer function, input signal, and time vector as inputs and returns the output signal. You can then use the plot function to plot the output signal against the time vector.

## 2. What is a transfer function and how is it used in MATLAB?

A transfer function is a mathematical representation of a system's output in relation to its input. In MATLAB, transfer functions are typically represented as ratios of polynomials and are used to analyze and design systems in control theory. They can be used to simulate, analyze, and design systems in various engineering disciplines.

## 3. Can I plot the output of a function with multiple inputs using a transfer function in MATLAB?

Yes, you can plot the output of a function with multiple inputs using a transfer function in MATLAB. In this case, you will need to use the ltisys function, which allows you to specify multiple inputs and outputs when defining the transfer function. You can then use the lsim function as before to plot the output signals.

## 4. How do I specify the time vector for plotting the output of a function in MATLAB?

The time vector for plotting the output of a function in MATLAB can be specified using the time function. This function takes in the start time, end time, and time step as inputs and returns a vector with evenly spaced time values. This vector can then be used as an input to the lsim function to plot the output signal.

## 5. Is it possible to plot the output of a function in real-time using a transfer function in MATLAB?

Yes, it is possible to plot the output of a function in real-time using a transfer function in MATLAB. This can be achieved by using the lsim function in conjunction with the animatedline function. The lsim function will continuously calculate the output signal, while the animatedline function will update the plot in real-time. This is useful for visualizing and analyzing systems in real-time.

• Engineering and Comp Sci Homework Help
Replies
1
Views
880
• Engineering and Comp Sci Homework Help
Replies
5
Views
2K
• Engineering and Comp Sci Homework Help
Replies
1
Views
658
• Engineering and Comp Sci Homework Help
Replies
8
Views
1K
• Engineering and Comp Sci Homework Help
Replies
3
Views
1K
• Engineering and Comp Sci Homework Help
Replies
12
Views
2K
• Engineering and Comp Sci Homework Help
Replies
10
Views
2K
• Engineering and Comp Sci Homework Help
Replies
23
Views
5K
• Engineering and Comp Sci Homework Help
Replies
12
Views
2K
• Engineering and Comp Sci Homework Help
Replies
1
Views
1K