Solve differential Equation for certain values of variable x

I have to find 4 values of z corresponding to x. After calculating differential equation how can I substitute x in the z(differential) equation? I have attached simplified code so that reader can understand.
x=[2 3 4 5];
syms x
z=diff(sin(x)-cos(x))

 Accepted Answer

Try this:
syms x
z(x)=diff(sin(x)-cos(x))
xVal=[2 3 4 5];
zVal=z(xVal)
What you need to do is to define a symbolic function z(x) and basically pass numeric values to that function as above. Really simple.

1 Comment

Thanks alot. it works. Sometimes I would make simple things complex.

Sign in to comment.

More Answers (0)

Categories

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!