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

Write a function called sinx that has three possible inputs: A, x and y and one

ID: 3603452 • Letter: W

Question

Write a function called sinx that has three possible inputs: A, x and y and one output: dydx. The aim of the function is to calculate the derivative and this can be done using the diff function Include a statement in your function to ensure that if the user only enters the first two inputs then y is defined in the function as y = Asin(x) Include a statement in your function to ensure that if the user only enters the first input, then y is defined in the function as y- Asin(x) and x is specified as a vector of 50 equally spaced points between 0 and pi. Finish your function with end and suppress all outputs

Explanation / Answer

function dydx=sinx(A,x,y)
if nargin==2
y=A*sin(x);
end
if nargin==1
x=linspace(0,pi,50);
y=A*sin(x);
  
end
dydx=diff(y);
end

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