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

 채택된 답변

Star Strider
Star Strider 2019년 10월 22일

0 개 추천

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

Hao Pan
Hao Pan 2019년 10월 22일
Thanks so much! It works perfect.
Star Strider
Star Strider 2019년 10월 22일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

질문:

2019년 10월 22일

댓글:

2019년 10월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by