Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Can you please write matlab code for this question and explain how to input it o

ID: 3887630 • Letter: C

Question

Can you please write matlab code for this question and explain how to input it or what to do exactly because I am not very knowlegable with matlab in general. Thanks

MATLAB Like many other programming software, Matlab can call already written programs (or m-files) and use them in the current running program. In the following problem you will create this type of m-file called a function and use it within another program. The basic layout of a user-written function is as follows: Function outputs = name of fun ction(inputs) Here is placed the code that manipulates the" inputs" data to result in the "outputs" where, name of function is the name used to call this specific function is an external code inputs are the data from the external code that is manipulated outputs are the data sent to the external code after manipulation The code should be saved in a file named name of function.m See help fiunction for more information on this command. name of See help fiunction for mone n a

Explanation / Answer

As shown in the above quesion,

I have created a function named unitstep which takes
input arguments as time (t)
Outputs as u.

Here for unitstep function the values of unitstep fucnion is 1 for all time is greater than zero.
so
u=1 for u>=0
u=0 for u<0

The below code satisfies the given requirement as follows:-

Q1:-

unitstep.m:-
--------------
function u = unitstep(t)
u = t>=0;
end

unit.m:-
---------
t = (-1:0.01:1)';
u = unitstep(t)


Q2:-

The below code satisfies the given requirement for quesion 2 to plot the graph

Q2.m:-
-------
fplot(@(t) (unitstep(t+5) - unitstep(t+2)),[-5 -2],'b')
hold on
fplot(@(t) t.^2,[-2 0],'b')
hold on
fplot(@(t) cos(2*pi*t),[0 5],'b')
hold off
grid on

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote