1
$\begingroup$

I have a function $g(x,y)= -2x+5y$ and vector $ a=\{0,2,6,8,18,20,24,26\} $.

I want to plot a $ g(1,a) $ but i don't know how to plot it?

I use following commands:

g[x_,y_]:=-2 x+5 y; 
Plot[g[1,y],{y,a}]

But i does not get a plot.

Please help. Thank you for help in advance.

$\endgroup$
1
  • $\begingroup$ Try ListLinePlot@Table[1~g~y,{y,a}] $\endgroup$
    – Wjx
    Commented Jun 22, 2016 at 6:45

3 Answers 3

2
$\begingroup$
a = {0, 2, 6, 8, 18, 20, 24, 26};
g[x_, y_] := -2 x + 5 y
g[1, a]

{-2, 8, 28, 38, 88, 98, 118, 128}

ListPlot[%]

enter image description here

$\endgroup$
0
$\begingroup$

You can also use DiscretePlot:

g[x_, y_] := -2 x + 5 y
DiscretePlot[g[1, y], {y, {0, 2, 6, 8, 18, 20, 24, 26}}]

enter image description here

$\endgroup$
0
$\begingroup$

Example

Code

a = {0, 2, 6, 8, 18, 20, 24, 26};
g[x_, y_] := -2 x + 5 y

ListPlot @ (g[1, #] & /@ a)

Output

example

Reference

Map
ListPlot

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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