Message Boards Message Boards

GROUPS:

Import a list of data and apply a function to one of the coordinates?

Posted 7 months ago
479 Views
|
1 Reply
|
1 Total Likes
|

I'm really new on programming and similar things, I have a data, import on math (with the command data= Import["PAtht"]) like {{x1,y1},{x2,y2}, etc etc}.. Is it possible to have a new list like {{f(x1),y1},{f(x2),y2}, etc (for example f(x)= a*x^2 with a = parameter ) I mean I wish to have a list of command to transform my data in new data and then plot the new data maybe also with a variable parameter .

Really thanx.

One way to do it is with replacement rules:

f[x_] := a x^2;
{{x1, y1}, {x2, y2}, {x3, y3}} /. {x_, y_} :> {f[x], y}

Then you can plot the result with ListPlot.

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract