Eventhough i used syntax for plotting xlabel, ylabel , title but its not visible in the graph

31 ビュー (過去 30 日間)
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 件のコメント
NITISH B
NITISH B 2021 年 10 月 10 日
function is x+exp(3*x)
interval is [0,1]
NITISH B
NITISH B 2021 年 10 月 10 日
x label ylabel title also i am not getting in the graph...Whats the problem?

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2021 年 10 月 10 日
Works for me.
syms x y
f(x)= x+exp(3*x) %input('Enter the function:');
f(x) = 
I= [0,1] %input('Enter the interval:');
I = 1×2
0 1
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');
Values of c lying in the interval I are
disp(double(c));
1.4019
T=f(c)+m*(x-c);
disp('The tangent Lines at c are');
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');

その他の回答 (2 件)

Cris LaPierre
Cris LaPierre 2021 年 10 月 9 日
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');
Values of c lying in the interval I are
disp(double(c));
1
T=f(c)+m*(x-c);
disp('The tangent Lines at c are');
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 件のコメント
Walter Roberson
Walter Roberson 2021 年 10 月 10 日
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
NITISH B 2021 年 10 月 10 日
built-in (/MATLAB/toolbox/matlab/graph2d/plot)
/MATLAB Drive/hold.m
like this for me showing in command window..by using which plot which hold

サインインしてコメントする。


Walter Roberson
Walter Roberson 2021 年 10 月 10 日
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 件のコメント
Walter Roberson
Walter Roberson 2021 年 10 月 10 日
movefile('/MATLAB Drive/hold.m', '/MATLAB Drive/was_named_hold.m')
NITISH B
NITISH B 2021 年 10 月 10 日
wow!!...Its working now ...Thanks a lot!! Sir..

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeFunction Creation についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by