ploting function and its derivative error

1 vue (au cours des 30 derniers jours)
Iqra Akhtar
Iqra Akhtar le 9 Mar 2021
I want to run this code but I am getting error conversion to double from sym is not possible please help
clear all
close all
syms x y z t
f=log(x)+sin(x);
y=diff(f,x,1);
z=diff(f,x,4);
t=diff(f,x,5);
x=0:1;
plot(f,x);
hold on
plot(y,x);
hold on
plot(z,x);
hold on
plot(t,x);
hold off
title('multiple plots of function and its higher order derivatives');
xlabel('x');
ylabel('y');
axis square
grid;

Réponses (1)

Star Strider
Star Strider le 9 Mar 2021
Use the fplot function:
syms x y z t
f=log(x)+sin(x);
y=diff(f,x,1);
z=diff(f,x,4);
t=diff(f,x,5);
x=0:1;
figure
fplot(f,x);
hold on
fplot(y,x);
fplot(z,x);
fplot(t,x);
hold off
title('multiple plots of function and its higher order derivatives');
xlabel('x');
ylabel('y');
axis square
grid
xlim([0 1E-3]) % <- AADDED (Optional)
.

Catégories

En savoir plus sur Mathematics dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by