69.6k views
1 vote
Practical Question" your answer should be by using computer" Let y 10 sin(t) and t will be from 0 to10 step 0.01 draw the y, the integration of y, and the derivative of y on the same plot A) using the MATLAB SIMULINK. B) using MATLAB programming.

User Sbeskur
by
8.7k points

1 Answer

4 votes

Answer:

To solve the practical question, we need to follow the steps:

A) Using MATLAB SIMULINK:

Open MATLAB and go to the SIMULINK library browser.

Drag and drop three integrator blocks and three derivative blocks onto the model canvas.

Connect the first integrator block to a sine wave block and set the frequency to 10 Hz.

Connect the output of the first integrator block to the input of the first derivative block.

Connect the output of the first derivative block to the input of the second integrator block.

Connect the output of the second integrator block to the input of the second derivative block.

Connect the output of the second derivative block to the input of the third integrator block.

Finally, connect all three integrator blocks to a scope block to display the output.

B) Using MATLAB programming:

Open MATLAB and create a new script file.

Initialize time vector t using the linspace function, with a start time of 0 and end time of 10, and a step size of 0.01.

Calculate y using the equation y = 10*sin(t).

Calculate the derivative of y using the diff function.

Calculate the integral of y using the cumtrapz function.

Create a new figure.

Plot y, the integral of y, and the derivative of y on the same plot using the plot function.

Add legends and labels to the plot.

Save the plot as a figure file using the saveas function.

Display the plot using the show function.

Here's an example MATLAB code for part B):

% Part B: MATLAB programming

% Define time vector

t = linspace(0, 10, 1001);

% Calculate y, the integration of y, and the derivative of y

y = 10*sin(t);

dy = diff(y)./diff(t);

dy = [dy(1),dy];

iy = cumtrapz(t, y);

% Plot the results

figure

plot(t, y, 'LineWidth', 2, 'DisplayName', 'y')

hold on

plot(t, iy, 'LineWidth', 2, 'DisplayName', 'Integral of y')

plot(t, dy, 'LineWidth', 2, 'DisplayName', 'Derivative of y')

xlabel('Time (s)')

ylabel('Amplitude')

title('Practical Question')

legend('Location', 'best')

grid on

% Save

Step-by-step explanation:

User Irshad Babar
by
7.7k points

Related questions

asked Sep 5, 2018 84.2k views
Steve Konves asked Sep 5, 2018
by Steve Konves
8.3k points
1 answer
4 votes
84.2k views