Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 1 Auto differentiating function - single order Step 1 Write a m -file function named y=Diff(v,n) , where v is a symbolic single variable

Problem 1\ Auto differentiating function - single order\ Step 1 Write a

m

-file function named

y=Diff(v,n)

, where\

v

is a symbolic single variable\

n

is a positive integer representing the order of differentiation\

y

is the

n

th derivative of the variable in the form of

Dnv

.\ For example,\ syms

x

y

abc

\ Diff

(x,2)

Step 2 Check for the positive and integer condition of the input n, and if it is not satisfied, then throw an error for it. For this purpose, look for isinf, floor, and error functions.\ Step 3 You should convert the symbolic variable

v

and the number

n

to strings, and then concentrate that with '

D

'. The result string can be turned to a symbolic variable using the matlab built-in function sym.\ Hint: Check the matlab built-in functions sym, char, and num2str help documents. Also, check how can you concentrate multiple strings in MATLAB.\ Step 4 write a test script, name it testDiff.m that check the output of the function as the above test script.

image text in transcribed
Step 1 Write a m-file function named y=Diff(v,n), where - v is a symbolic single variable - n is a positive integer representing the order of differentiation - y is the nth derivative of the variable in the form of Dnv. For example, syms x y abc Diff (x,2) ) D 2x Diff (y,5) D 5y Diff (abc,3) > D 3abc Step 2 Check for the positive and integer condition of the input n, and if it is not satisfied, then throw an error for it. For this purpose, look for isinf, floor, and error functions. Step 3 You should convert the symbolic variable v and the number n to strings, and then concentrate that with ' D '. The result string can be turned to a symbolic variable using the matlab built-in function sym. Hint: Check the matlab built-in functions sym, char, and num2str help documents. Also, check how can you concentrate multiple strings in MATLAB. Step 4 write a test script, name it testDiff.m that check the output of the function as the above test script

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Cybersecurity In Finance

Authors: Sylvain Bouyon, Simon Krause

1st Edition

1786612178, 9781786612175

Students also viewed these Databases questions