0
$\begingroup$

Does anyone how can I plot this? I got many errors saying Infinite expression 1/0. I want to plot each one on a separate graph from top to bottom with legend about the values of a, b, c, m, n, p.

f1[a_, b_, c_, d_, m_, n_, p_] := -((m + d (a + b - m - n) + n) /(
c d + p - d p));

Block[{t =
Table[f1[a, b, c, d, m, n,
p], {a, {-1, 0, 1}}, {b, {-1, 0, 1}}, {c, {-1, 0, 1}}, {m, {-1,
0, 1}}, {n, {-1, 0, 1}}, {p, {-1, 0, 1}}]}, Plot[t, {d, 0, 1},PlotLegends ->{"a" = a, "b" = b, "c"=c, "d"=d, "m" = m, "n" =n, "p" = p]]
$\endgroup$
1
  • 2
    $\begingroup$ Try f1[a_,b_,c_,d_,m_,n_,p_]:=If[(c*d+p-d*p)==0,0,-((m+d(a+b-m-n)+n)/(c*d+p-d*p))]; Table[Print[Plot[f1[a,b,c,d,m,n,p],{d,0,1},PlotLegends->"{a,b,c,m,n,p}="<>ToString[{a,b,c,m,n,p}]]],{a,-1,1},{b,-1,1},{c,-1,1},{m,-1,1},{n,-1,1},{p,-1,1}]; $\endgroup$ – Bill Dec 2 '20 at 20:07
1
$\begingroup$

You may want to consider using Manipulate to look at the various plots.

f1[a_, b_, c_, d_, m_, n_, p_] := 
  ConditionalExpression[-((m + d (a + b - m - n) + n)/(c*d + p - d*p)), 
    (c*d + p - d*p) != 0];

Manipulate[
 Plot[f1[a, b, c, d, m, n, p], {d, 0, 1},
  Frame -> True,
  FrameLabel -> (
    Style[#, 12, Bold] & /@ {"d", "f1(d)"}),
  PlotLabel -> "{a,b,c,m,n,p} = " <>
    ToString[{a, b, c, m, n, p}]],
 {{step, 1}, {0.1, 0.2, 0.25, 0.5, 1}},
 Delimiter,
 {{a, -1}, -1, 1, step, Appearance -> "Labeled"},
 {{b, 0}, -1, 1, step, Appearance -> "Labeled"},
 {{c, -1}, -1, 1, step, Appearance -> "Labeled"},
 {{m, 0}, -1, 1, step, Appearance -> "Labeled"},
 {{n, 0}, -1, 1, step, Appearance -> "Labeled"},
 {{p, 1}, -1, 1, step, Appearance -> "Labeled"}]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.