How to solving and plot only one non-linear equation with two or one variables without using ezplot

I want to solve and plot one non linear equation with two variables k and f, the equation is shown here, where k varies from 0 to 1. The other algebras are given.
(((2*pi*f).^2)/((2*pi*fv).^2)-1)*((2-(((2*pi*f).^2)/((k.^2)*(cs.^2))).^2)-4*((1-(((2*pi*f).^2)/((k.^2)*(cs.^2)))).^0.5)*((1-(((2*pi*f).^2)/((k.^2)*(cl.^2)))).^0.5)-m*(((2*pi*f).^4)/(A*(cs.^4)*den*(k.^3)))*((1-(((2*pi*f).^2)/((k.^2)*(cl.^2)))).^0.5))=0
For every k value, there are more than one possible solutions for f value, where the f value can be in form complex number and is limited from 0 to 20.
However, it gives 'The input to FSOLVE should be either a structure with valid fields or consist of at least two arguments.' after running the command.
Apart from that, i actually want to plot a continous function rather than scattering the point if it is possible. I don't want to use ezplot because the plot is not correct. Thankyou
clc
clear all
syms k f
cs = 121;
cl = 227;
A = (1.3^2)*(3^0.5)/2;
den = 1300;
m = 6700;
fv = 4.9;
k=0:0.01:1;
fun = @(f) ((2*pi*f).^2)/((2*pi*fv).^2)-1)*((2-(((2*pi*f).^2)/((k.^2)*(cs.^2))).^2)-4*((1-(((2*pi*f).^2)/((k.^2)*(cs.^2)))).^0.5)*((1-(((2*pi*f).^2)/((k.^2)*(cl.^2)))).^0.5)-m*(((2*pi*f).^4)/(A*(cs.^4)*den*(k.^3)))*((1-(((2*pi*f).^2)/((k.^2)*(cl.^2)))).^0.5)));
fsolve(fun, [0, 20])
scatter(k,f)
ylim([0 20]);
xlim([0 1])

Respuestas (1)

Numerical way
[K,F] = mehsgrid(-10:10);
Z = your_function
contour(K,F,Z,[0 0]) % contour at 0 level

11 comentarios

It gets some error when running.
Error using contour (line 55)
DOUBLE cannot convert the input expression into a double array.
If the input expression contains a symbolic variable, use VPA.
Error in analytical (line 20)
contour(K,F,Z,[0 0])
Is it a 1D graph? Because i want it to be 1D rather than 2D or 3D. Thankyou
my full code is shown here
clc
clear all
syms f k
cs = 121 %ok
cl = 227 %ok
A = (1.3^2)*(3^0.5)/2 %ok
den = 1300 %ok
m = 6700 %ok
fv = 4.9
[K,F] = meshgrid(-10:10);
Z = ((((2*pi*f).^2)/((2*pi*fv).^2)-1)*((2-(((2*pi*f).^2)/((k.^2)*(cs.^2))).^2)-4*((1-(((2*pi*f).^2)/((k.^2)*(cs.^2)))).^0.5)*((1-(((2*pi*f).^2)/((k.^2)*(cl.^2)))).^0.5)-m*(((2*pi*f).^4)/(A*(cs.^4)*den*(k.^3)))*((1-(((2*pi*f).^2)/((k.^2)*(cl.^2)))).^0.5)))
contour(K,F,Z,[0 0])
ylim([0 20])
xlim([0 1])
Although there is no error, it doesnt give a correct plot. For every K, there are more than one F values, is there other approach to get the plot for the nonlinear equation?
clc
clear all
syms F K
cs = 250
cl = 468
A = 1.3
den = 1600
m = 10500
fv = 2.43
sz = 10
[K,F] = meshgrid(-10:10);
Z =((((2.*pi.*F).^2)./((2.*pi.*fv).^2)-1).*((2-(((2.*pi.*F).^2)./((K.^2).*(cs.^2))).^2)-4.*((1-(((2.*pi.*F).^2)./((K.^2).*(cs.^2)))).^0.5).*((1-(((2.*pi.*F).^2)./((K.^2).*(cl.^2)))).^0.5)-m.*(((2.*pi.*F).^4)./(A.*(cs.^4).*den.*(K.^3))).*((1-(((2.*pi.*F).^2)./((K.^2).*(cl.^2)))).^0.5)))
contour(K,F,Z,[0,0])
ylim([0 20])
xlim([0 1])
This is how your plot looks like if
surf(K,F,Z)
So contour at level 0 is correct
how about if i want to obtain the data the f corresponding to k for the equation
i.e. k f
0.1 abc
0.2 def
0.3 ghi
0.4 jkl
but can you use fsolve to find the solution of f value where k=0:0.01:1
What about interp1? fsolve is used for equations

Iniciar sesión para comentar.

Categorías

Más información sobre Mathematics en Centro de ayuda y File Exchange.

Productos

Versión

R2015a

Preguntada:

el 14 de Feb. de 2020

Comentada:

el 17 de Feb. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by