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

 Akzeptierte Antwort

Star Strider
Star Strider am 22 Okt. 2019

0 Stimmen

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 Kommentare

Hao Pan
Hao Pan am 22 Okt. 2019
Thanks so much! It works perfect.
Star Strider
Star Strider am 22 Okt. 2019
As always, my pleasure!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Hilfe-Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by