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

Please answer all questions in matlab code. Thanks! MATLAB Like many other progr

ID: 3887529 • Letter: P

Question

Please answer all questions in matlab code. 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

% define unitstep function in unitstep file

Function (o,n)= unitstep(i,n)

if ~isvector( i)

error('Input should be a vector')

end

n=length(i);

for k=1:n

if(i<0)

o=0;

end

if (i==0)

o=0.5;

end

if(i>0)

o=1;

end

end

% call the function

unitstep(i,n);

Q2)

%define the function

function [o,x]=unitstep(t,k)

k=-5:0.01:10; %k is the time vector

n=length(t);

end

end

%call the function

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