how to use loop in function to plot

1 visualización (últimos 30 días)
shiv gaur
shiv gaur el 8 de En. de 2022
Editada: Walter Roberson el 10 de En. de 2022
function y=f(x)
np=1.5;
a=1.2;
b=3;
x=np*sin(theta);
k1=sqrt(a-x^2);
k2=ksqrt(b-x^2);
y=(k1-k2)/(k1+k2);
end
how to determine the delta(y)/ delta(x)/ with the variation of theta;
delta means change in value of parameter how to write using loop
pl help to plot delta(y)/delta(x) vs theta
  3 comentarios
shiv gaur
shiv gaur el 8 de En. de 2022
Dr torsten you can take the value of theta between 0 to 2*pi yo are req to help in earlier problem also thanks
Walter Roberson
Walter Roberson el 8 de En. de 2022
how to determine the delta(y)/ delta(x)/ with the variation of theta;
x is a function of theta, so you are asking to take the derivative of function y with respect to function x,

Iniciar sesión para comentar.

Respuestas (2)

Walter Roberson
Walter Roberson el 8 de En. de 2022
syms x(theta)
np=1.5;
a=1.2;
b=3;
X=np*sin(theta);
k1=sqrt(a-x^2);
k2=sqrt(b-x^2);
y=(k1-k2)/(k1+k2);
dydx = functionalDerivative(y,x)
dydx(theta) = 
dydtheta = simplify(subs(dydx, x, X))
dydtheta(theta) = 
fplot(dydtheta, [-2*pi 2*pi])

Mathieu NOE
Mathieu NOE el 8 de En. de 2022
hello
try this
I modified your function because x and y are both outputs
theta = linspace(0,2*pi,100);
figure(1)
[x,y]=f(theta);
dx = gradient(x);
dy = gradient(y);
plot(theta,dy./dx);
%%%%%%%%%%%%%%%%%%%
function [x,y]=f(theta)
np=1.5;
a=1.2;
b=3;
x=np*sin(theta);
k1=sqrt(a-x.^2);
k2=sqrt(b-x.^2);
y=(k1-k2)./(k1+k2);
end
  2 comentarios
shiv gaur
shiv gaur el 8 de En. de 2022
if three variable are there what will be change in program pl modified this
shiv gaur
shiv gaur el 8 de En. de 2022
Editada: Walter Roberson el 10 de En. de 2022
sir we modified the program like that
theta = linspace(0,2*pi,100);
figure(1)
[x,y]=f(theta);
dx = gradient(x);
dy = gradient(y);
plot(da,dy/dna./dx/dna);
%%%%%%%%%%%%%%%%%%%
function [x,y]=f(theta)
np=1.5;
nb=2;
x=np*sin(theta);
k1=sqrt(na^2-x.^2)+na;
k2=sqrt(nb^2-x.^2)+da;
y=(k1-k2)./(k1+k2);
end
so to calculate the dy/dx is written as dy/dx =dy/dna /dx/dna so there are three
gradient and fourth one is da so you are requested to plot in this manner vs da
pl

Iniciar sesión para comentar.

Etiquetas

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by