Eventhough i used syntax for plotting xlabel, ylabel , title but its not visible in the graph
Afficher commentaires plus anciens
clear
clc
syms x y
f(x)=input('Enter the function:');
I=input('Enter the interval:');
a=I(1);b=(2);
Df=diff(f,x);
m=(f(b)-f(a))/(b-a);
c=solve(Df==m, x);
c=c(a<c&c<b);
disp('Values of c lying in the interval I are');
disp(double(c));
T=f(c)+m*(x-c);
disp('The tangent Lines at c are');
disp(vpa(y==T,4));
figure
fplot(f,I); grid on; hold on;
fplot(T, I, 'r');
plot(c,double(f(c)), 'ko');
plot(I,double(f(I)), 'm');
xlabel('x'); ylabel('y');
title('Demonstration of Mean value theorem');
3 commentaires
Walter Roberson
le 10 Oct 2021
What function and interval are you using?
NITISH B
le 10 Oct 2021
NITISH B
le 10 Oct 2021
Réponse acceptée
Plus de réponses (2)
It works fine for me
clear
clc
syms x y
f(x)=x.^2; % modified so code runs here
I=[0 10]; % modified so code runs here
a=I(1);b=(2);
Df=diff(f,x);
m=(f(b)-f(a))/(b-a);
c=solve(Df==m, x);
c=c(a<c&c<b);
disp('Values of c lying in the interval I are');
disp(double(c));
T=f(c)+m*(x-c);
disp('The tangent Lines at c are');
disp(vpa(y==T,4));
figure
fplot(f,I); grid on; hold on;
fplot(T, I, 'r');
plot(c,double(f(c)), 'ko');
plot(I,double(f(I)), 'm');
xlabel('x'); ylabel('y');
title('Demonstration of Mean value theorem');
6 commentaires
NITISH B
le 10 Oct 2021
Could you remind us which MATLAB release you are using?
Also, does "hold on" generally work for you? For example what happens if you try
plot(rand(1,30), 'displayname', 'first')
hold on
plot(rand(1,30), 'displayname', 'second')
plot(rand(1,30), 'displayname', 'third')
hold off
legend show
NITISH B
le 10 Oct 2021
Walter Roberson
le 10 Oct 2021
I just tried it myself in MATLAB Online, and got all three lines.
When you are on MATLAB Online, what shows up if you command
which plot
which hold
NITISH B
le 10 Oct 2021
Walter Roberson
le 10 Oct 2021
1 vote
You have your own hold.m that is interfering with the Mathworks command. You need to rename it or delete it or put it in a directory named "private" in the code that needs it.
3 commentaires
NITISH B
le 10 Oct 2021
Walter Roberson
le 10 Oct 2021
movefile('/MATLAB Drive/hold.m', '/MATLAB Drive/was_named_hold.m')
NITISH B
le 10 Oct 2021
Catégories
En savoir plus sur Argument Definitions dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



