plot the equation graph
Mostrar comentarios más antiguos
how to plot graph V vs x
equation is
V*sqrt(1-x)=m*pi+atan((x)/(1-x))+atan((a+x)/(1-x))
taking V=1:10
m=0
a=1;
then plot V vs x
3 comentarios
Wan Ji
el 30 de Ag. de 2021
It's your homework, not our duty to help you. Your words are impolite and made me uncomfortable. I delelted the code that I wrote. Looking back to the questions you've asked, you are lacking in basic respect and gratefulness to others who have helped you. Hope you behave yourself better
shiv gaur
el 30 de Ag. de 2021
shiv gaur
el 30 de Ag. de 2021
Respuestas (1)
Wan Ji
el 30 de Ag. de 2021
Hi,
It is not neccessary to solve this equation
x = 0:0.00001:1;
f = @(x,m,a)(m*pi+atan((x)/(1-x))+atan((a+x)/(1-x)))./sqrt(1-x);
m = [0,1,2];
a = [0,10,1e15];
V1 = f(x,m(1),a(1));
V2 = f(x,m(1),a(2));
V3 = f(x,m(1),a(3));
plot(V1,x)
hold on
plot(V2,x)
plot(V3,x)
V1 = f(x,m(2),a(1));
V2 = f(x,m(2),a(2));
V3 = f(x,m(2),a(3));
plot(V1,x)
hold on
plot(V2,x)
plot(V3,x)
V1 = f(x,m(3),a(1));
V2 = f(x,m(3),a(2));
V3 = f(x,m(3),a(3));
plot(V1,x)
hold on
plot(V2,x)
h = plot(V3,x);
axis([0, 15, 0, 1.1])
grid on

8 comentarios
shiv gaur
el 30 de Ag. de 2021
shiv gaur
el 30 de Ag. de 2021
shiv gaur
el 30 de Ag. de 2021
Is this the right way to access x when V = 0:10?
the main function
function main
mu = 0;
a = 1;
V_arr = 0:1:15;
[V_arr, X_arr] = getX(V_arr,mu(1),a(1));
plot(V_arr, X_arr,'rs-','markerfacecolor','r','markersize',10);
axis([0 15 -0.5 1])
end
function [V_arr, xnorm] = getX(V_arr,mu,a)
f = @(V,x,m,a)V*sqrt(1-x)-(m*pi+atan((x)/(1-x))+atan((a+x)/(1-x)));
m = mu;
a = a;
x0=-0.999;
x1=0;
x2=0.999;
TOL=1e-14;
Nmax=1000;
% V_arr = 0:1:15;
X_arr = zeros(size(V_arr));
for i = 1:1:numel(V_arr)
V = V_arr(i);
X_arr(i) = muller(@(x)f(V,x,m,a), x0, x1, x2, TOL, Nmax);
% X_arr(i) = real(fsolve(@(x)f(V,x,m,a), 0.8));
end
% xnorm = (X_arr-min(X_arr))/(max(X_arr)-min(X_arr));
xnorm = X_arr;
end
Muller method
function X = muller(f, x0, x1, x2, TOL, Nmax)
for n=1:Nmax
h1=x1-x0;
h2=x2-x1;
d1=(f(x1)-f(x0))/h1;
d2=(f(x2)-f(x1))/h2;
a=(d1-d2)/(h2+h1);
b=d2+h2*a;
c=f(x2);
t=x2-(2*c*sign(b))/(abs(b)+sqrt(b^2-4*a*c));
s=f(t);
if abs(s)<TOL
break
else
x0=x1;
x1=x2;
x2=t;
end
end
X = real(t);
end

shiv gaur
el 30 de Ag. de 2021
shiv gaur
el 30 de Ag. de 2021
Wan Ji
el 30 de Ag. de 2021
you can change x0,x1 and x2 to get more roots if there are
shiv gaur
el 25 de Sept. de 2021
Categorías
Más información sobre Creating, Deleting, and Querying Graphics Objects en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!