problem in plot of given equation

1 visualización (últimos 30 días)
shiv gaur
shiv gaur el 5 de Feb. de 2022
Editada: Abhaya el 24 de Sept. de 2024
df=1:300;
nc=1.33;
ns=1.5;
nf=1.59;
theta=10:60
y=zeros(length(theta),length(df))
x=1.5*sind(theta);
l=632.8;
zfc=(l/2*pi)*sqrt(x.^2-nc.^2);
zfs=(l/2*pi)*sqrt(x.^2-ns.^2);
p=1;
de=df+zfc+zfs
y=(nc/x)*((nf^2-x^2)./(nf^2-nc^2))*(zfc/de)*(2*(x/nc)^2-1)^p;
plot(df,y)
iI have problem to plot the graph
  1 comentario
M.MUSBA Elhadid
M.MUSBA Elhadid el 5 de Feb. de 2022
The sizes of vectors that are input arguments to plot function have to be the same. So you have to check it.

Iniciar sesión para comentar.

Respuestas (1)

Abhaya
Abhaya el 24 de Sept. de 2024
Editada: Abhaya el 24 de Sept. de 2024
Hi Shiv,
The error you are encountering occurs while adding the vectorsdf’,zfc’, andzfs’, which have different sizes. Specifically, the vectordf’is of size 1x300, whilezfc’andzfs’are calculated based on the vectortheta’, which is of a size 1x51. To resolve this issue, you can make vectorthetaof size 1x300 using MATLABlinspace’function.
theta=linspace(10,60,300);
Additionally, when calculating 'y', ensure that you are using element-wise operations to handle each element of the vectors individually. The code given below shows how you can assign values toy’:
y=(nc./x).*((nf^2-x.^2)./(nf^2-nc^2))*(zfc/de).*(2*(x/nc).^2-1).^p;
Please refer to the code snippet given below, to resolve the error.
df = 1:300;
nc = 1.33;
ns = 1.5;
nf = 1.59;
% adjust theta to match the size of df
theta = linspace(10, 60, 300);
x = 1.5 * sind(theta);
l = 632.8;
zfc = (l / (2 * pi)) * sqrt(x.^2 - nc.^2);
zfs = (l / (2 * pi)) * sqrt(x.^2 - ns.^2);
p = 1;
% ensure df, zfc, and zfs are compatible in size
de = df + zfc + zfs;
% using element-wise operations to handle each element of the vectors individually
y = (nc ./ x) .* ((nf^2 - x.^2) ./ (nf^2 - nc^2)) .* (zfc ./ de) .* (2 * (x ./ nc).^2 - 1).^p;
plot(df, y);
For more information on linspace’, please follow the MATLAB documentation for linspace’ function.
Hope this helps.

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

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