Plot multiple implicit functions

I plotted a simple single implicit function using fimplicit code below. I'm wondering how to plot multiple implicit functions. For example, I want to use fimplicit to plot multiple f(x,y) with intervals of S defined in the function, i.e. S=1:0.1:2
Maybe fimplicit is not a good option. Could anyone advise other plot commands how to plot f(x,y) with multiple S intervals?
%% Main
fun = @f1;
fimplicit(fun, [-2 2 -2 2],'r');
%% Function
function z = f1(x,y)
a=1;h=1;p=1;tau=0;m=10;S=1;
K1 = (x+h*y)/2;
K2 = (((x-h*y)/2).^2+(p*tau).^2).^(1/2);
c = 2-a;
z = a*(abs(K1+K2).^m) + a*(abs(K1-K2).^m) + c*((2*K2).^m) - 2*(S^m);
end

 Respuesta aceptada

Star Strider
Star Strider el 22 de Oct. de 2019
Try this:
%% Main
Sv = 1:0.1:2; % Define The Range Of ‘S’ As A Vector
figure
hold all
for k = 1:numel(Sv)
fimplicit(@(x,y)f1(x,y,Sv(k)), [-2 2 -2 2]);
end
hold off
grid
%% Function
function z = f1(x,y,S)
a=1;h=1;p=1;tau=0;m=10;
K1 = (x+h*y)/2;
K2 = (((x-h*y)/2).^2+(p*tau).^2).^(1/2);
c = 2-a;
z = a*(abs(K1+K2).^m) + a*(abs(K1-K2).^m) + c*((2*K2).^m) - 2*(S^m);
end
Note that it is necessary to remove the assigned value of ‘S’ inside ‘f1’, so the passed parameter is the value the function uses.

2 comentarios

Hao Pan
Hao Pan el 22 de Oct. de 2019
Thanks so much! It works perfect.
Star Strider
Star Strider el 22 de Oct. de 2019
As always, my pleasure!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre 2-D and 3-D Plots en Centro de ayuda y File Exchange.

Preguntada:

el 22 de Oct. de 2019

Comentada:

el 22 de Oct. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by